The angularjs controler 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

3
votes
1answer
10 views

specifying AngularJS controller: benefits using ngController vs. $routeProvider

There are two ways (AFAIK) to associate a controller with a view template/partial: the route specified in $routeProvider and the ngController directive. Especially (but not exclusively) for simple ...
0
votes
1answer
13 views

Controller is not getting updated factory value

I'm updating an object property in a factory and it doesn't seem to be updating the property referenced in the controller. Say I have a factory that looks something like this... app.factory('User', ...
0
votes
1answer
15 views

AngularJS - How to get directive-controller in directive with “require”

I have a directive with a require. Now I want to get the required controller instance AND the controller of the directive in the link function. How is that possible? If i set 'require' the fourth ...
0
votes
1answer
17 views

angular controller script execution: once or multiple times?

I previously thought that the controller script would only be executed once, when my single page application is loaded. Now I see that every time I change a view my controller script executes again. ...
0
votes
1answer
15 views

Angular: where should I track div 'expanded' state?

I'm new to Angular so this is a question about best practices and separation of concerns. Let's say I have the following setup <div ng-controller='SomeCtrl'> <div ng-repeat="item in ...
1
vote
2answers
26 views

What is difference between following agularjs controller definition? [duplicate]

var app = angular.module('myApp', []); app.controller('myController', ['$scope', function($scope, []) { ..... }]); and var app = angular.module('myApp', []); app.controller('myController', ...
0
votes
1answer
35 views

AngularJS controller scope won't sync with promise

I've picked up a project and I'm trying to return some data from a service to my controller. I've been at this for about 12 hours, and have tried different methods. They all usually result in this ...
0
votes
0answers
21 views

Function decomposition of ngTables?

Attempt: $scope.ran_before = false; function table(provider, columns, params, data, parse_data) { params = new ngTableParams ( { page: 1, // show first page ...
0
votes
1answer
28 views

Getting data from a Controller/Service into a Directive?

I'm a relative beginner with AngularJS and am writing an app that will have various reusable components (e.g. the same table may appear 5 times on the screen, with slightly different columns - I can ...
0
votes
1answer
12 views

Passing parameters to controller in AngularJs

I am new to AngularJs. I have a details page where I display the link like below: <a href='/device-summary/"+ full.link.href+"'>"+ data_to_be_displayed+"</a> In the above link, the ...
0
votes
2answers
64 views

No data returned in consuming REStful web service using Angularjs

I am beginner learning Angularjs .Please help me with examples for following script added javascript - var app = angular.module('myapp', []); app.controller('MyCtrl1', ['$scope', ...
1
vote
1answer
41 views

Factory property is null when accessing directly from controller Angular

I'm trying to build simple loggin with angular and rest api and I've got strange problem with checking whether user is logged in login form controller. Here is my code: everytime I refresh my app it ...
0
votes
3answers
21 views

How to escape an angular scope variable in a kiwi template

I have a scope variable (myVar) which is defined in MyController: angular.module('myApp.controllers').controller('MyController', ['$scope', function($scope) { $scope.myVar = 'whatsoever'; }]); ...
1
vote
2answers
66 views

AngularJS call common controller function from outside controller

My basic premise is I want to call back to the server to get the logged in user in case someone comes to the site and is still logged in. On the page I want to call this method. Since I am passing ...
0
votes
2answers
41 views

angularjs directive controller $element

i see angularjs highly suggested not to do any dom manipulation in the controller, only setting the state of the scope, example pulling data from ajax etc, https://docs.angularjs.org/guide/controller ...
0
votes
1answer
27 views

AngularJS register controller once

That's what I'm doing. There is application with pages and different controls that may be put on pages by site admin/editor. All pages share one ng-app defined on master page. All controls are ...
0
votes
1answer
45 views

updating controller over service not updating view

in my app I have an "Maps" to show and handle things on maps. A CtrlMap controller display the map and shows an marker. The watchPosMap watches position changes. 3rd there is an service called ...
0
votes
0answers
31 views

Associating a controller with a nested template?

Angular lets me associate a controller with a template in several different ways: With anguluar-route: app.js $routeProvider.when('/foobar', {controller: "FooCtrl", templateUrl: ...
0
votes
1answer
23 views

passing parameters to filter function defined on a controller

Say I have a (extremely simplified) controller defined like so: app.controller('myController', ['$scope', function(scope){ list=[1,2,3,4,5] scope.filterFunction = function(item, ...
0
votes
2answers
54 views

Directive talks to controller but cannot call functions residing in controller

I have a directive which needs to call functions from the Main controller but everytime i try to reference a function inside the directive nothing happens because it's undefined. When I access a value ...
1
vote
1answer
16 views

How to append a directive to another directive which calls a function from controller.

I'm trying to append a directive which occurs when an event is fired via the $watch function in angular. The first directive updater would insert a custom element <confirmation /> into my view. ...
0
votes
1answer
38 views

Initiating directive from controller

I'm having trouble figuring out a way to initiate a directive once the data has been returned. I'm trying to build a report using html tables and ng-repeat. The report object is generated using a ...
1
vote
1answer
23 views

How to remove repetitve function from angularjs controller

Hi i am writing some code staff under angularjs but i has to make duplicated code from controller to other for example let's assume that we have two controllers editProductController and ...
-2
votes
1answer
48 views

Avoid Hard Coding Controller name Angularjs

I am a beginner in angular..I have a requirement to avoid hard coding any names in the app.. I have used myapp.constant("constantName", { "name":"name1" }); to avoid hard coding html..I would ...
0
votes
0answers
15 views

$scope.$digest throwing“No more request expected ” in angular controller unit test

Controller code : $scope.$watch('model.time_zone', ((newValue, oldValue) -> return if (newValue == oldValue) if newValue == originalTimeZone $scope.timeZoneChanged = false else ...
0
votes
1answer
36 views

Angular directive - when to prefer using a controller inside a directive?

I've been seing a lot of directive containing a controller in it. What are the pro / cons /differences and use cases compared to put the same code in the link function of the directive ? One ...
0
votes
1answer
46 views

$stateParams returning undefined

I have these routes defined: .state('sport', url: '/sport' templateUrl: '/templates/sport' controller: 'SportCtrl' ) .state('sport.selected' url: '/:sport' ...
0
votes
1answer
58 views

ngRouter/uiRouter preserve controllers when changing view

Is there anyway to preserve route controllers in Angular when using routing? Everytime I change the view, the old controller is destroyed and a new one created, but I was wondering if there was a way ...
1
vote
3answers
64 views

Best practice for defining scope variables

I have this form. This form contains many many inputs like first name, last name, job title, notes, state, department, documents, supervisor...and so on Originally I had a controller like so ...
0
votes
2answers
37 views

Get parent controller in child controller which all use 'controller as vm' notation

Parent controller set to 'parentCtrl as vm' and chield set to 'childCtrl as vmc' to be no name conflict and it works well. How can I get access to parent controller in child controller? Note that ...
2
votes
1answer
39 views

How can we test non-scope angular controller methods?

We have few methods in Angular Controller, which are not on the scope variable. Is anyone know, how can we execute or call those methods inside jasmine test? Here is main code. var testController ...
0
votes
1answer
83 views

Routing with controllers in these html pages, is it possible?

I'm new in AngularJS development and I'm actually in front of a problem. In my index.html I have already many scripts included like that : <script type="text/javascript" ...
1
vote
2answers
35 views

In an AngularJs directive, how do I call its controller's function contained within an directive element's attribute?

I am trying to call a function in a controller, which is part of a custom angular directive, following is the code, Method 1: (Doesn't work: Controller's function doesn't write to the console) HTML: ...
1
vote
2answers
58 views

How to pass async data from directive to controller?

I want to compile a third-party api (uploadcare) to a directive. The api will return the data info after uploaded in async then I want to do something with the return data in my controller but I have ...
0
votes
1answer
59 views

AngularJs pass item property in ng-repeat to controller

I need to pass an item property in an ng-repeat to the controller like this: <li ng-repeat="feed in feeds | filter:customFilter(feed,feed.publishedDate) "> Sending feed.publishedDate like ...
1
vote
1answer
38 views

AngularJS controller executes twice (not because of router)

From what I read, the most common cause of this problem is when the controller is included in the template and in the route provider. In my case, only the parent template containing this html is being ...
0
votes
1answer
93 views

changing model objects inside controllers to manipulate DOM - angular js- Best practices?

I hava a simple question after reading the post below and working for some time now on angular js. the post : no dom manipulation from angular js controllers the concerned point (from the post) : ...
0
votes
1answer
71 views

Passing a callback form directive to controller function in AngularJS

I have a directive and a controller. The directive defines a function in its isolate scope. It also references a function in the controller. That function takes a callback. However, when I call it ...
1
vote
0answers
65 views

Angular directive in ng-repeat doesn't call link

I'm fairly new to Angular and am having some trouble getting a directive to render within an ng-repeat. This is probably a lack of experience on my part so any help is greatly appreciated. Here are ...
0
votes
2answers
68 views

AngularJs ngShow triggers double in controller

I have a problem with the controller triggering the method defined on the $scope twice when the page first loads and when the form submits. Here's the fiddle : http://jsfiddle.net/scabro/pQb6q/5/ ...
0
votes
1answer
80 views

AngularJS Factory Service Controller $http.get

I am trying to retrieve the "cart" in the following way Factory->Service->Controller. I am making an $http call but it is returning an object. If I debug I can see that the request is made and is ...
0
votes
2answers
100 views

angularJS scope not updated for function attribute inside promise block

controller('SomeController', function($scope, simpleFactory, $routeParams) { init(); function init() { var myDataPromise = simpleFactory.getStuff($routeParams.id); // The ...
2
votes
3answers
109 views

How do I access the $scope variable of one controller from another in Angular.js?

I have this: app.controller('foo1', function ($scope) { $scope.bar = 'foo'; }); app.controller('foo2', function ($scope) { // want to access the $scope of foo1 here, to access bar }); How would ...
1
vote
1answer
132 views

AngularJS sharing data between factory & controller across modules

I have an angularjs app that has several modules. The main modules looks something like: var app = angular.module('mainMod', ['apiService']); app.controller('MainCtrl', function (Socket) { ...
0
votes
1answer
187 views

Angular ui.router, call parent controller function from child controller?

I'm using Angular with ui.router and have setup a nested view. The parent view has a div whose visibility I can toggle through a function on the parent controller. I'd like to call this function from ...
0
votes
2answers
41 views

How to convert this AngularJS controller in this module to another format?

I have this AngularJS controller; angular.module('plunker', ['ui.bootstrap']); var TabsDemoCtrl = function ($scope) { $scope.tabs = [ { title:"Dynamic Title 1", content:"Dynamic content 1" }, ...
1
vote
2answers
136 views

AngularJS & Typescript: How to assign a class/type as a directive's controller?

AngularJS directives specify a controller using: { controller: function ($scope){} } As of yet, I have not found a way where I can create a TypeScript class and assign it to a directive's ...
0
votes
1answer
30 views

error while defining an angluarjs controller

I'm new on AngularJS and for me 'its hard to understand the basics. Maybe I get something wrong, but can't find the reason. I have an view (insight index.html) like that: <body ng-app="mainApp" ...
1
vote
1answer
96 views

Unit test angularjs controller

I've been looking through countless SO post on this but can't get the unit test of my angular controller to work. Error: TypeError: Object #<Object> has no method 'apply' Error: [ng:areq] ...
0
votes
1answer
173 views

angularjs - how to get in the controller the index of an item in a ng-repeat filter based on the value of one of its properties?

I use a ng-repeat in my html file to display filtered items: <li ng-repeat="item in (filteredItems = (items | filter:query))"> {{ item.name }} </a> In the controller, I'd like to ...