The AngularJS controller exposes the data that is to be displayed into the html view. It plays the essential role of the ModelView in the MVVM design pattern. The view is a part of the HTML template.

learn more… | top users | synonyms

8
votes
3answers
203 views
+100

AngularJS controllers, design pattern for a DRY code

I have created a full example for the purpose of describing this issue. My actual application is even bigger than the presented demo and there are more services and directives operated by every ...
0
votes
1answer
28 views

Setting a two-way bound directive attribute in the HTML with AngularJS

I'm just starting out with AngularJs and have run into an issue that might be the result of not understanding directives / controllers /isolated scope properly. I'm trying to find a way to set a ...
1
vote
0answers
16 views

jquery metismenu not working loading data async with AngularJS controller

I have a problem with Jquerymetis menu. I want to load menu elements from Database and I'm using AngujarJS controller to get the JSON with menu elements. Here is AngularJSController var ...
0
votes
1answer
150 views

Error while defining an angularjs controller

I have an view (insight index.html) like that: <body ng-app="mainApp" ng-controller="MainCtrl"> [...] <div>{{status}} </div> </body> I start the App onDeviceReady: ...
0
votes
2answers
43 views

Function in Controller not being hit

First time asking a q, so if I'm doing something wrong, please let me know so I can fix it as I have tried finding the answer on here, but can not, so any and all help would be greatly appreciated. ...
0
votes
1answer
25 views

Pass object down to the child directive results in unexpected undefined

It's like third day im confused by this, and I'm going crazy already. The intro I'm writing an app in which, among others, I'm registering people - creating entry for person with plenty of related ...
31
votes
11answers
46k views

Error: [ng:areq] from angular controller

This is a long shot, but has anyone seen this error before? I am trying to add 'Transporters' using express, angular and mongoDB. I get this error whenever I access a page ruled by the transporters ...
1
vote
2answers
34 views

how to do easily the group of filtering conditions in angularjs?

I have four filtering such as JobType,Experience,DateAdded and Salary i want to do filtering as individual and group. For it i defined a filter as filterType in my controller and added to template ...
0
votes
2answers
35 views

How to share a variable between multiple modules in AngularJS

I'm new to AngularJS and understand the basic principles. However, I'm having a case now where I don't yet know how to get to the solution. Let me briefly explain you the case. Let's say you have a ...
0
votes
2answers
27 views

AngularJS - $rootScope variable initialization fails

I'm trying to initialize a $rootScope array variable (arrayX) and use it in a $rootScope function in the same controller (controllerA). The reason i'm using $rootScope instead of $scope for this ...
195
votes
12answers
139k views

AngularJS : How can I pass variables between controllers?

I have two Angular controllers: function Ctrl1($scope) { $scope.prop1 = "First"; } function Ctrl2($scope) { $scope.prop2 = "Second"; $scope.both = Ctrl1.prop1 + $scope.prop2; //This is ...
0
votes
1answer
25 views

How to use variable from a Controller in a Directive link function?

I want to be able to use the variable "videoUrlId" from the controller 'useSpreadsheetData' below in my directive 'meetings'. How can I do this? I have looked at require but could not get it to work. ...
1
vote
1answer
25 views

Directive hierarchy & bindToController

I encountered an issue while writing an AngularJS directive. I'm actually trying to melt two principles, directive inheritance and using the controller object (the famous this) instead of $scope. I ...
1
vote
1answer
16 views

Induce controller UI change from within directive with shared variable

So i have a controller which hides/shows part of its template based on value, let's say its something like this: <div ng-show="isSelected"></div> ... $scope.isSelected = true; ... ...
1
vote
5answers
46 views

How to access the scope of a parent's controller's in a directive's controller?

I have a custom directive nested in a parent div who's controller sets a variable value to its scope, such as: html <div ng-controller="mainCtrl"> <p>{{data}}</p> ...
0
votes
0answers
24 views

Detect Forward and Backward Routes througth a Button - AngularJS

Plenty of folks have asked how to detect back button clicks/gestures in AngularJS but that is really only half of the equation. In order to use ngAnimate transitions, specifically a slide left on ...
0
votes
2answers
20 views

How to read the concatenated string as a variable in angularjs?

In my angular controller i defined $scope.flag1 = false; $scope.flag2 = false; $scope.flag3 = false; I need to read those variable in my view page as bellow <div flex="30" flex-sm="100" ...
0
votes
1answer
24 views

how to change the custom attribute value using angularjs controller?

i have used material design class in my app. <div flex="30" flex-sm="100" ng-repeat="shortListLoad in user.shortListLoads"> <md-button class="md-icon-button md-primary" ...
0
votes
1answer
27 views

How to update Directive on State Changes

I have a root state that defines the overall structure of the Angular template. In the root state, I have the sidebar included that has dynamic menus via directive that changes based on the state. ...
0
votes
2answers
23 views

$scope.$watch() is not picking up service object changes

I've written a service for extending the offcanvas library. It's all dandy however I can't seem to get the state object to propagate to my controller. I'm watching for state changes but nothing seems ...
13
votes
2answers
9k views

Getting AngularJS Error: “[$rootScope:inprog] $digest already in progress” without a manual $apply

Other posts on this error always include someone trying to $apply without using a safe apply, but that's not the case in my example. My function IS successfully returning the data I requested from the ...
1
vote
0answers
58 views

Not able to display data passed from MVC controller to angular factory

I am returning a List<User> from MVC controller JSON but I am unable to load my user details on my view. Here is my code : UserMasterController.cs public class UserMasterController : ...
1
vote
1answer
2k views

Unknown provider: bProvider <- b

I have an AngularJS project with Directives and Controllers. After a while i got this error when I tried to run it: Error: [$injector:unpr] Unknown provider: bProvider <- b I have googled it and ...
0
votes
3answers
35 views

Angular evaluating ng-show slowly

I have a simple verification that evaluates in my controller: <span class="....." ng-show="!ruleHasAnsweredQuestions()"> Please answer all questions</span> In the controller: ...
3
votes
2answers
89 views

Extracting common controller functionality into base controller

The web app I'm working on has a view of a Person entity. We have several controllers that perform CRUD operations on data of that Person (e.g. phone numbers, email addresses, etc.). In turn, these ...
2
votes
2answers
487 views

Is controller inheritance a good practice in AngularJS?

I am new to AngularJS and i don't know if "Is controller inheritance a good practice in AngularJS?". I mean that if I have 2 almost the same controllers like here: ...
11
votes
2answers
13k views

Angular.js best practice - extending controllers, overriding controller defaults

Here is a real-life Angular problem I can't wrap my head around. I love Angular, but this issue is bugging me a lot right now. What is the best practice to extend an existing controllers's functions, ...
1
vote
3answers
42 views

How exactly is an AngularJS controller defined?

I have a question related to the syntax of controllers and the way they are declared in AngularJS. I'm fairly certain I know how they work, but my question is related to the syntax. So I might have ...
0
votes
1answer
38 views

angularjs - get from a factory returns null on page refresh

I have two controllers(and two views) and a factory. I set a property in the factory from the first controller.Then I redirect to the second page. When I try to get the property from the factory in ...
2
votes
2answers
17 views

TypeError: api.getAll is not a function, service method is not recognized

I have a very simple service and a controller attempting to get some information from it, but I keep getting .methodName is not a function. Here is the service, apiService.js : (function (module) ...
0
votes
2answers
26 views

AngularJS issue injecting services

Not really sure where I'm going wrong here. I'm trying to simply inject a service and use it in controller app.js var app = angular.module('myApp', [ 'myApp.controllers.myCtrl', ...
6
votes
2answers
72 views

What is the correct way to access controller that was required inside directive controller?

I have a directive with require property: require: '^testBox' now I want to get testBox controller inside controller of my directive. How should I do it? I was trying to do so: controller: ...
1
vote
1answer
28 views

angularjs changing factory object shared between controllers

Is it possible to update the scope variable that points to a factory object, after the factory object is updated? If there are 2 angular controllers which share a factory object, if one of the ...
1
vote
0answers
30 views

Can I change variables of pre defined constants in angularJs?

I defined a constant 'ngGPlacesDefaults' which sets default values of 'google place search' config file. But now I want to change the values of defaults dynamically i.e types:['airport'], ...
106
votes
7answers
53k views

AngularJS : The correct way of binding to a service properties

I’m looking for the best practice of how to bind to a service property in AngularJS. I have worked through multiple examples to understand how to bind to properties in a service that is created using ...
0
votes
1answer
26 views

Error: $injector:modulerr Module Error angularjs

I am just learning angularjs, with the following code I have been getting this error ==> Error: $injector:modulerr Module Error Here is the code, what is going wrong here? <!doctype html> ...
1
vote
1answer
25 views

AngularJS - use a service and controller in a directive

I am trying to use a service and controller in a directive. I have a button directive, on click of the button, i want to call a controller method() and call a service inside that method(). ...
0
votes
1answer
19 views

AngularJS - Not able to access service in a controller method

I am not able to access a service inside my controller method. AppController.$inject = ['$scope', 'appService']; function AppController($scope, appService) { $scope.name = "World"; ...
0
votes
0answers
32 views

Making a directive load before ngController

I am trying to get experience with angular by making an app (for my own use) and I ran into an issue. I decided to try to implement lazy loading (like in the "Complex" part of the answer to this ...
0
votes
0answers
31 views

AngularJS - how to change an object from parent crtl in the child ctrl without using scope?

How to change an object from parent crtl in the child ctrl without using $scope? Example: myApp.controller("ParentController", function () { var pvm = this; pvm.index = 0; }); ...
0
votes
0answers
16 views

Access to form data that submitted by an unknown source

Scenario: Another web application get a link from my web app and then POST some data to the link, like this: <form action="http://www.example.com/mylink"> <input type="hidden" ...
0
votes
1answer
25 views

ng-describe/Angular/Karma unit testing: Compiling a directive with a required controller using ng-describe's setupControllers

I'm writing Karma unit tests for angularJS using ng-describe (which I must say, is awesome). I've got two directives. I want to test directive testing which requires somethingController. code: ...
0
votes
1answer
24 views

How to use angularjs ui router nested views with multi controllers and require js

I'm working on a angular project with angular-ui-route and the use of nested views like: $stateProvider.state('app', { url: '/form', views: { 'p1@modals': { ...
1
vote
1answer
45 views

AngularJS - Controller one a compiled directive

As the name suggests, what is the difference? A controller is suppose to act as a constructor - to instantiate all the variables and/or make API calls. A directive's controller also runs before the ...
0
votes
3answers
39 views

how to call a function to load an array in angular js

I am reading values from json file. I created a sample json file. contact.json: [ { "id":"1", "Name":"abc" } ] I created a service class ContactsService. ...
1
vote
2answers
49 views

What is the issue with this sample code in Angular Js

I am learning angularJS. I have tried a calculator using angularJS. Two combo boxes having inputs and the other combo box is having the operations. When the user clicks the button then it has to show ...
0
votes
1answer
31 views

Unable to sync AngularJS service with controllers (angular.copy)

I have set up two controllers (Controller A and Controller B) and a service (Service). I am attempting to sync the data from controller A to the service, and present that information to Controller B. ...
1
vote
2answers
463 views

AngularJS passing data to bootstrap modal

Hi guys here I think I'm missing something but cannot figure what. Basically I'm trying to pass an object to the modal like below, but instead of getting the passed object I gets null...so I think is ...
1
vote
2answers
45 views

Using AngularJS service to update scope in other controller from other module

I am a newbie for AngularJS so maybe I am looking at this the wrong way. If so, please point me in the right direction. Basically I want to update some DOM elements that reside in another controller ...
1
vote
1answer
31 views

Why am I getting the Angular $injector:modulerr error here? Using 1.5 beta

The markup <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Angular ...