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

0
votes
0answers
12 views

How should a controller be specified in a directive?

Assume we have these 2 snippets, what's the difference between controller: function (...) { } and controller: 'myController' app.directive('testDirective', function () { return { restrict: ...
0
votes
0answers
8 views

Karma jasmine testing for controllers

I have a controller defined inside $stateProvider.state for which i am writing some unit tests. The issue is this controller is not defined with a name and i am not able to access it. Controller ...
6
votes
4answers
13k views

Calling directives methods from parent controller in AngularJS

I am using AngularJS with the alias controllers pattern. I can't access (or I don't know how to) directive methods from a parent controller. I have a function inside my controller that should call a ...
222
votes
14answers
164k 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 ...
1
vote
1answer
31 views

Angular app with ui-router not hitting controller unless its inline function

I am having trouble with ui-router. If I use an inline function it works, otherwise when I click on the route the controller is not used. I can debug the browser and the js is being delivered but no ...
126
votes
6answers
171k views

How do I use $rootScope in Angular to store variables?

How do I use $rootScope to store variables in a controller I want to later access in another controller? For example: angular.module('myApp').controller('myCtrl', function($scope) { var a = ...
1
vote
1answer
25 views

angular directive controlleras and link

I have markup like this <i class="fa-font icon-user" wd-user-profile></i> to show / hide this div <div id="user-profile" ng-show="vm.isVisible"> <h3>user name</h3> ...
0
votes
0answers
25 views

Organizing a composite angular js directive

As part of creating a complex grid control, I've been writing a directive which builds this composite control that uses multiple controls within. The master control consists of a core grid control, a ...
0
votes
1answer
11 views

Angular Unit Testing: Isolate certain components defined on module

I've inherited a large AngularJS project using Karma and Jasmine and am trying to follow the conventions that were set out before me, but am having trouble unit testing directive/controller modules. ...
0
votes
1answer
38 views

Angular 2 component inside Angular 1?

I want to add an Angular 2 component inside my Angular 1 controller, so the Angular 1 controller is a parent and Angular 2 component is a child. I would like a child and parent be able to exchange ...
0
votes
3answers
21 views

Not being able to iterate through inputs within scope

I'm trying to iterate through an array created using angular, so I can add them up and then show them, but the problem is, I'm getting an error saying that property '1' of undefined even if I fill out ...
1
vote
1answer
34 views

In AngularJS, how do we decide to have one or more controllers?

Let's say if a page has the left panel with some items to choose from, and the right side having a "cart" panel, then would it be good to have 2 controllers: 1 for the left panel, and 1 for the right ...
0
votes
1answer
38 views

Order and Groupd Data By Year and Month

I am trying to show a list of payments made for a particular product. So, if i purchased a product for $2000, i would could set up a monthly payment of $100 and i want to try and track if that payment ...
0
votes
1answer
47 views

Angular JS : How do I Lazy load my directive?

my html structure is like below main.html <div class="row"> <div class="col-xs-9" id="myResultPage"> <!-- Code for service call to get the results ...
0
votes
2answers
27 views

Select with multiple columns in AngularJS not working properly?

Demo link Hi all, I created a sample for select with multiple columns in AngularJS. which is working fine if I pass the value directly like this: $scope.rowDatas = [ { ID: ...
0
votes
1answer
21 views

How to pass routeparams value in model window angularjs?

In my project I am trying to implement modal window for the edit screen. I have listed screen where users need to select one row from the list and click the modify button. I need to open the edit ...
0
votes
1answer
35 views

What is OWASP ? why we need that? [closed]

I read some documents they said OWASP is used for security purpose for web application. But Am not clear about that. can any one tell me the purpose, what is the difference normal app(without owasp) ...
1
vote
3answers
78 views

How to test response from service within controller

I am trying to test the response from a service http call that is performed within a controller: Controller: define(['module'], function (module) { 'use strict'; var MyController = function ...
3
votes
2answers
140 views

AngularJS ControllerAs syntax and controller injected variables

I'm writing a directive and trying to stick to the John Papa style guide. So I've also decided to jump on the ControllerAs syntax wagon and I've got a tiny directive like below: (function() { ...
0
votes
2answers
51 views

Angular.js controller that uses multiple services

I can't seem to figure how to inject multiple services into a controller. I have listed my files here: index.html file: <script src="'./angular/angular.min.js'></script> <script ...
4
votes
1answer
38 views

Change a value inside ng-repeat cycle with ng-click

I want to change a value of an item inside an ng-repeat cycle using a function. This for example won't work. HTML <ul class="unstyled"> <li ng-repeat="todo in todoList.todos"> ...
1
vote
3answers
45 views

AngularJS: code not working when iterating through object [duplicate]

I am trying to populate a list of employee objects from my controller empctrl in a template. Here's the controller: app.controller('employeeController', function ($scope, employeeService) { ...
0
votes
1answer
26 views

Mock Service Within Controller Returning Undefined

I am trying to test something pretty simple: a controller that calls a service that performs a http request. Controller: define(['module'], function (module) { 'use strict'; var ...
36
votes
15answers
58k 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 ...
3
votes
1answer
35 views

ng-repeat not working with onsen ui

I'm going nuts, this is such a small thing but I can't find a solution... I have this js file (the angularjs app is initialized in the begining of the html document) app.controller('slidingMenuCtrl', ...
0
votes
1answer
27 views

How to read variable of a directive from a controller in angularJS

I downloaded an angularJS module which does multi date picker for me (composed from 1 factory and 1 directive), and I integrated them in the module that I am already building. It works fine even ...
0
votes
9answers
76 views

Cannot write a basic controller AngularJS

Forgive me if my question is too basic. I am learning AngularJS's controllers. This is the project structure. This is my html: <!doctype html> <html ng-app> <head> ...
0
votes
2answers
277 views

All AngularJS Controllers Not Loading with LazyLoad

I am trying to lazy load my controllers for my AngularJS app I built along side with requireJS. I have created a custom "lazyLoad" library that creates a resolve object in app.config() routes (also I ...
7
votes
3answers
5k views

Using AngularJS and jsPlumb (use jsPlumb functions in AngularJS controller)

So I have a project that I am working on and it requires that I use jsPlumb for graphical elements connections and I am building my app entirely using AngularJS. What is the procedure to follow if I ...
25
votes
2answers
6k views

Accessing inherited scope with Controller As approach

With the original way to define controllers, accessing the parent's scope was fairly trivial, since the child scope prototypically inherits from its parent. app.controller("parentCtrl", ...
2
votes
1answer
175 views

Initialize $scope variables for multiple controllers - AngularJS

I have 3 controllers that do similar tasks: PastController queries an API for past system outages. CurrentController queries an API for current system outages FutureController queries an API for ...
11
votes
2answers
305 views

How to do autocomplete dropdown as a grid in angularJS?

Here I created sample for autocomplete, which is working fine and I need to do some modification on this.currently it works like this but what I exactly need is I need to show the dropdown as grid ...
1
vote
1answer
42 views

Angularjs controller function vs directive function

Lately I've been building some modules and in some of them I only used controllers (controller is set within an existing directive I already need to use to load template) to have this comunnication ...
1
vote
2answers
41 views

Angular JS: can we set resolve or promise on controller which did not have route defined?

I am trying to fetch some data from server before controller get render. I have found many answers for it with respect to routeProvider. But my main issue is my controller does not bound with any ...
1
vote
1answer
28 views

Argument 'indexController' is not a function, got undefined

This has been asked before but it didn't answer my question. I am pretty new to angular and I am just putting things together at the moment. I am trying to get my factory to work inside my controller. ...
0
votes
1answer
37 views

Pass $scope data from controller to view

I want to display $scope.predicate and $scope.reverse values into my view(in the <p> tag ). It seems that using {{ }} expression is not working. app.js: var app = angular.module('testApp', ...
-1
votes
1answer
42 views

How to get Values from Other AngularJs Controller $scope variable

I'm having two controllers namely AController and BController. I need to get the value of Controller AController's $scope.myName to the Controller BController's $scope.myName. Note: Here I'm not ...
1
vote
2answers
39 views

Unable to call parent controller method from directive

I've seen the many, many, many, many questions on this problem but for some reason I still can't bind ng-click in my directive to a method on the parent controller. I'm pretty sure I've got my scope ...
0
votes
1answer
21 views

Change child scope using broadcast from app.run

I have an angular app with the name DemoProject. I have an app.run controller and one child controller JS var app = angular.module("DemoProject", ['ngRoute', 'ngAnimate', 'ngMessages', ...
0
votes
0answers
16 views

Change Values for an angularJS child Controller property in app.run

I having a angular module app in the name of the ng-app DemoProject. Now I'm creating app.run controller and one child controller My AngularJS Script var app = angular.module("DemoProject", ...
0
votes
2answers
47 views

How to change Selected Tab inside controller in angularjs?

Here I created Sample For Tabs. What I exactly need is inside sample controller manually I need to set selected tab based on config parameter. At load time I need to set manually the tab to be ...
0
votes
4answers
57 views

console.log for $scope in angualr js

Why I'm not able to console output $scope values ? I'm trying to extract user assigned values from the pages and retrieve in controller. Eventually i would like to pass this to service so multiple ...
0
votes
1answer
22 views

How to do dynamic Helpcontext with anchor scroll in angularjs?

Here I created a sample for a dynamic Help Context. Based on the page it will load dynamic help data which is working fine. In local $anchorScroll is also working fine. What I need exactly is while ...
1
vote
1answer
71 views

Scope Variable undefined in angularjs typescript controller class of directive

I have created wrapper directive over ag grid as below function MyDirective(): ng.IDirective { var directive = <ng.IDirective>{ restrict: "E", template: '<div ...
1
vote
2answers
29 views

POSTing item from ng-repeat

I have a simple ng-repeat, that displays a list of addresses. Next to each address is a button, when clicked, i want to perform a HTTP:POST. I know know how to perform a REST call, but im struggling ...
2
votes
2answers
1k views

Customize AngularJS Bootstrap Tooltip

How do I add custom placements/animations to an AngularJS/Bootstrap tooltip? I can do: myApp.controller('TooltipCtrl', function ($scope) { $scope.htmlTooltip = 'Here is a tooltip!'; }); And it ...
-1
votes
0answers
20 views

How to find my Angular bugs? [duplicate]

I am using the framework Angular.js. My problem is, that it is hard to find a bug in my own code. Always when I do something wrong (no matter how small the problem is) the whole code doesnt work ...
13
votes
3answers
10k 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 ...
3
votes
3answers
47 views

Difference in controller declaration in AngularJS

I have seen controller being declared in two ways as below. But what diff does this make? appmodule.controller('Actrl',['$scope',function($scope) {}]); appmodule.controller('Actrl',function($scope) ...
0
votes
0answers
22 views

create multiple jqxwindow with angularjs

I'm beginner in AngularJS and I want to create multiple jqxwindow with AngularJS. How can I do it with Angularjs-directive or AngularJS-controller?