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

0
votes
1answer
18 views

Where is the controller placed using $routeProvider?

With ng-controller="myController" you know exactly what DOM element is associated with the controller, because it's put directly into your HTML: <div ng-controller="myController"> with ...
0
votes
2answers
17 views

Scope issue in $http success callback

I'm using PHP to get data into my factory, which shows correctly in the success callback function within the controller. However, even after assigning the returned data to $scope.customers, it's not ...
1
vote
1answer
13 views

angularjs controller in PartialView not working

I have a View which contains a link to call a PartialView. <div data-ng-controller="MainController"> <a href="#" data-ng-click=callPartialView()"> Click here to see the ...
0
votes
1answer
23 views

Angular how to get ID of element for controller instance

I have an angular app that may have multiple pages open that use the same controller. I need to be able to reference DOM elements that are specific to one instance of the controller. For example: ...
0
votes
0answers
19 views

can controllers be separate files while sharing data between controllers through a service?

I'm doing something like this: How to create separate AngularJS controller files? But I'm trying to share data between these separate controllers using a service. I'm unable to do it. Can you tell ...
0
votes
1answer
16 views

how to return rejected/failure promise to through jasmine spy to an angular controller in a unit test

I am using jasmine for testing my angular controllers. I am catching errors and success in the .then(successCallback, errorCallback) Although it is working fine on the bases of live functionality but ...
0
votes
2answers
32 views

Can't get this.var to bind correct data in AngularJs

Two Important Notes: 1. My goal is to AVOID using $scope in this case since it's my understanding that impedes the new "controller as" syntax. 2. My problem is likely a variable scope issue and so ...
0
votes
1answer
17 views

Accessing Parent controller variables in child controllers Angularjs

I have an issue, i would like to take your suggestion on this. I have used child controller inside parent controller div . e,g, <div ng-controler="parent"> <div ...
0
votes
0answers
21 views

Angularjs reload part of the document

I know that the whole page can be reloaded using the $window.location.reload(); but is it possible to just reload one part of the page? I'm building a mobile app and it loads the data from the local ...
0
votes
0answers
20 views

Angularjs - inject controller dependency automatically in $scope

Is there a way to inject automatically a dependency (or a resolve) in the $scope without manually append it to $scope ? (with or without UI-Router) Would the "controllerAs" syntax be of any help ? ...
0
votes
2answers
32 views

How to use ControllerAs feature of angular in gridOptions

I'm trying to use the ControllerAs in Template but result is blank. the construct of my controller is like: app.controller("MyController",function(){ this.result=getResult(); ...
0
votes
0answers
18 views

getting : undefined is not a function on getting collection from web-api

I have a web api which returns IHttpActionResult(myCollection) on Get. My angular JS controller is has a function : $scope.loadcollection = function($defer, params) { console.log("inside ...
0
votes
2answers
33 views

Difference of function(javascript) vs scope.function(angular function) defined in controller

I want to know the difference between declaration of this two function in angular controller function demo() { }; scope.demo = function() { ...
0
votes
1answer
65 views

$scope.$emit not working while $rootScope.$broadcast does

Here's my parent controller where I listen for the event app.controller("SectionLayoutController", function($scope) { $scope.$on("sectionLayout.doAction", function(e, options) { // do some ...
1
vote
0answers
30 views

getting an error : Argument 'ctrl' not defined in angular js

my index.html file has the following : <script src="scripts/controllers/form/DashboardCtrl.js" /> <script src="scripts/controllers/chart/morrisChartCtrl.js" /> my app.js file is as ...
0
votes
1answer
51 views

Sharing a controller scope between two directives with isolate scopes in AngularJS

I have two directives that provide different views on the same set of data. Both of these directives need to rely on central functionality contained in a controller. The controller uses various ...
1
vote
1answer
35 views

AngularJS directive using another controller

I'm trying to create a directive that will output a HTML-template that is using data from a controller. In sample.js I've added a module, controller and directive var app = angular.module("myApp", ...
0
votes
2answers
35 views

Combining ng-repeat and ng-controller to render item

I'm trying to assign a controller per item of a list so that I'm able to manipulate the list item data. The displayed information differentiate for each item. <div ng-repeat="item in items" ...
0
votes
1answer
34 views

How to $http.post with payload in data?

How do I post data from a form in AngularJS? <form data-ng-submit="doSomething()"> <input type="text" data-ng-input="do_obj.text"/> <input type="email" ...
0
votes
1answer
54 views

Angularjs: controller init function avoid init to be called

I have the following controller code: applicationControllers.controller('PostsController', ['$scope', '$http', function ($scope, $http) { var page = 1; $scope.init = function() { ...
0
votes
1answer
33 views

Where to put in logic for manually adding and removing classes for an anchor tag - Angular JS

I have a main html page in which I have an anchor tag (looks like a button explained below), a drop down with some values and a check box. Code is given below. I have an anchor tag that makes it ...
0
votes
2answers
39 views

AngularJs Directives Loaded Event

I have just started using AngularJs directives, using the resources here, here and here. I have a situation where i need to do something after all directives have been loaded. i.e Scenario 1 ...
1
vote
2answers
31 views

Altering $scope controller variables on URL

I have a simple web app that is just a table with formatted JSON data. When you click on a column, you can filter that column in ascending order. I would like for actions like that to change the url ...
0
votes
1answer
24 views

angularjs app design multiple instances of the same component (directive or directive+controller)

My app needs to have multiple instances of a component that manages a complex model. to display the model and the UI/DOM logic including a template with child directives I'v created a directive, the ...
0
votes
2answers
35 views

Send Object From Directive to Parent Controller in AngularJS

How can I send an object back from a directive into the parent controller? I've defined the following directive: app.directive('inspectorSharedObjects', function () { return { restrict: 'E', ...
0
votes
0answers
21 views

Isolating large amounts of information into factories from controllers (AngularJS)

I'm a little new to Angular, so I'm not really sure what the standards are when it comes to writing an app that has something like this. I had some functions and content I needed to share across ...
0
votes
2answers
17 views

Referencing the element that is calling a controller function Angularjs ( ng-change / ng-blur / ng-* ? )

The original question asked about how to determine which element called the controllers blurr function, but I didn't clarify that I was not specifically asking about ng-blur, but ng-* (ng-change, ...
0
votes
1answer
21 views

Referencing the element that's calling a controller function Angularjs

Fairly simple but I can't figure out the term I need to google. How do I reference whichever element is calling the controllers blurr function? html <body ng-app="test"> <div ...
0
votes
1answer
44 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
1answer
30 views

Trying to call method in service from a controller

I'm trying to call a method in a service from a controller and am receiving the error: 'TypeError: undefined is not a function'. Does anyone see anything wrong with how I have things set up? valid.js ...
1
vote
1answer
97 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: ...
0
votes
2answers
35 views

Dynamic tabs in Angular-UI fails?

Created this simple test-case which shows the error occuring: HTML <tabset ng-repeat="tab in tabs"> <tab heading="{{tab.title}}"> <i ...
0
votes
1answer
27 views

Missing prototype methods in controller

I'm retrieving plain json data via my service and then attaching some behaviour to it via a constructor and prototype methods. When this object is returned from the service to the controller, I can ...
0
votes
1answer
44 views

Call controller method from directive

I have a button which change the "active" state. First, it loads the status from the server <button active="data.active" ng-click="changeStatus()"></button> directive code: ...
-1
votes
0answers
22 views

AngularJS: Communicating to a controller function outside ng-view controller

Can someone help me in the following scenario.. I am developing a two page application say dahsboard and search. In my index.html, I created a header view with header controller and ng-view to load ...
0
votes
2answers
24 views

AngularJS accessing an attribute in a directive from a controller

I need to pass an Id defined in the directive to the associated controller such that it can be used in a HTTP Get to retrieve some data. The code works correctly in its current state however when ...
0
votes
1answer
26 views

Global search using filters and services

My purpose is to create a global search toolbar, where I can search any data in the app. I'm already using filters to search a single type of resource, like : <div ng-repeat="project in projects ...
1
vote
2answers
35 views

why / when to use multiple controller - Angularjs

I started working with AngularJs recently. Looking to understand the reason for using multiple controller, I found different site explaning how to use multiple controller (AngularJS site). But what ...
-2
votes
0answers
36 views

Angular JS Controller not working

I am new to AngularJS, and unable to figure out why this basic controller is not working given the following code. It should take in two numbers and run a simple calculation(addition or ...
0
votes
1answer
48 views

Update AngularJS Controller Scope from Another Controller/Scope

Hopefully this hasn't been asked.. I looked around and haven't found anything yet. I have a single view that provides the user with a modal dialog (wizard) to create a few things and then save them. ...
0
votes
0answers
68 views

AngularJS: $scope.array.push() does not update the view, even with $apply

I'm trying to learn AngularJS and there is this thing that I don't understand, which seems like all the internet solved by using $scope.$apply, but I already use it and it does nothing. Basically, I ...
0
votes
0answers
16 views

Obtaining a reference to another controller function from within a controller

I want to dynamically set ng-controller within an ng-repeat. See this question for more details. The linked question shows how to do this by defining the controller functions in the global ...
0
votes
3answers
34 views

AngularJS controller $scope reserved keyword?

I am a newbie to Angular, I came across this fiddle which explains how nested controller works. When I rename $scope to something else say $abc and it doesn't work, does it mean that $scope is a ...
2
votes
1answer
70 views

How do I assign an attribute to ng-controller in a directive's template in AngularJS?

I have a custom attribute directive (i.e., restrict: "A") and I want to pass two expressions (using {{...}}) into the directive as attributes. I want to pass these attributes into the directive's ...
0
votes
0answers
19 views

How different controllers can relay of each other while page is being loaded?

Think about this simple scenario: <div ng-controller="ctrl1"> ... drop down list... </div> <div ng-controller="ctrl2"> ...grid list... </div> The first <div> ...
1
vote
1answer
50 views

Filter data with AngularJS from JSON file

I am creating a "word of the day" functionality in a web app and I have a JSON file with the following data structure. I couldn't get myself to dump 730+ entries into the HTML under ng-init to filter ...
2
votes
1answer
28 views

How to avoid code duplication when using controllers with similar methods?

Say I have following controllers: controller("MyCtrl1", ["$scope", "$sce", "myService", "$location", function ($scope, $sce, myService, $location) { $scope.Resources = ...
0
votes
1answer
55 views

using angularjs controller that consumes a service promise inside the view

I have an controller that consumes an angularjs service promise. I have written jasmine unit tests against the controller and therefore the controller function looks like: this.getTodos = function () ...
0
votes
1answer
39 views

How to get the actual current controller on $routeChangeSuccess

I have a global routechangesuccess event handler for tracking route changes as "Page Loads" to our analytics platform. Currently, I am using the current controller name in the routechangesuccess ...
0
votes
1answer
35 views

Angular.js “Controller As” on templateUrl/template ng-click/blur/focus events not working?

I know this has to be a simple thing I'm overlooking, but google is not being my friend right now. When using the "controllerAs" syntax, for some reason if I use it for an element within a template, ...