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
1answer
31 views

Defining angular controllers and component

I'm trying to call a function from within one angular component's controller to another component's controller. I found this answer, but the controllers are defined differently than what is shown in ...
1
vote
5answers
756 views

How can I have multiple controller files?

SOLVED So after viewing your responses and making minor changes to my code, I found a simple typo which prevented me to reach the result I was after. So thank you all to helping with where I was ...
160
votes
7answers
54k views

Can an AngularJS controller inherit from another controller in the same module?

Within a module, a controller can inherit properties from an outside controller: var app = angular.module('angularjs-starter', []); var ParentCtrl = function ($scope, $location) { }; app.controller(...
1
vote
1answer
15 views

reference form in angular component without scope

Currently I have this component definition: var controller = ['$http', '$timeout', '$scope', function($http, $timeout, $scope) { this.isInvalid = function() { return $scope....
1
vote
0answers
17 views

Best way for a form controller to expose parsed data from the form it manages?

I come from a Java background and am getting up to speed on Angular 1.5.8+typescript. I have a form controller that crunches the raw fields from a form and produces a data structure. An example of ...
0
votes
2answers
2k views

AngularJS : Use factory inside a controller

I use angularjs seed and trying to write a simple factory and insert it in to the controller. I have a Row factory definition angular.module('myApp') .factory('Row', [ function () { return 'some ...
0
votes
1answer
41 views

How to pass ngModel to AngularJS component without 2-way binding?

I have custom input as AngularJS 1.5 component with one-way data bindings and ngModel as two-way data binding: return { bindings: { form: "<", fieldName: "@", minLength: "...
35
votes
3answers
9k 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", function($...
2
votes
1answer
42 views

injecting a list into a json format

I'm new with angularJs and i want to inject a list of string that i get it using a restful web service into a jSON list. And how can the connections list could proceed object returned by ...
0
votes
2answers
30 views

angularjs controller access directive scope value

I have this controller with directive inside my html code. The directive have scope value I would like access from the parent controller and show in the html. Hope my example code give you a simple ...
1
vote
3answers
33 views

Why is AngularJS Controller not working on my pc?

I have started learning MEAN Stack and wanted to try some code but AngularJs Controller is not working on my PC. I have windows 10 on my Acer Aspire V Nitro. Can anyone please help. Will be highly ...
0
votes
0answers
86 views

Why isn't my AngularJS view updating?

(Update: still haven't solved this.) (Further update: I've had no further responses from anyone. Surely this must be solvable?) I'm combining Angular and D3, which I think is causing some problems. ...
3
votes
1answer
32 views

scope issue with ng-view, parent controller, custom directive

I'm so confused about my situation. Let me briefly introduce my situation. HTML structure. (It's just structure, full HTML is more than that but there is no any other controller except "...
0
votes
2answers
27 views

AngularJS updating form with select and passing parameters into controller

I have a pretty simple itemController which contains an array of items (in actuality, these are obtained from an API). I want to then call the API again to get the subsections based on what is ...
4
votes
2answers
315 views

Using this instead of $scope inside controller

I am trying to follow style guide for angular and there wrote we should use this insted scope... Styleguide Could someone explain me when I am able to use this? Here is my try..... What I am doing ...
0
votes
2answers
41 views

What exactly 'this' means in AngularJS controller?

index.html <body ng-controller="StoreController as s"> <h1 ng-click="s.changeValFunc()">{{s.carname}}</h1> <h2>{{s.carname}}</h2> </body> app.js var app =...
1
vote
2answers
41 views

Controller not defined AngularJS

I get this error when I try to run my application. Argument 'CampaignsSettingsController' is not a function, got undefined My controller is defined here: // Called Second var ...
1
vote
1answer
98 views

Getting error when pass data between controllers using sample service

as part of angular js learning, i created small app that will pass the data between two controllers using services..below is my code to pass the data between two controllers.. Controller code <!...
49
votes
19answers
80k 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
3answers
61 views

Error: [ng:areq] Argument 'ControllerName' is not a function, got undefined

In app.js I have: (function(){ var app = angular.module("myApp", []); })(); in process.js which is included after app.js I have: (function(){ app.controller('ProcessController', ['$http', ...
0
votes
2answers
27 views

Can a controller be in a seperate file when using ng-view?

Currently I am learning AngularJS. I have made a 'hello world' app that displays through the ng-view directive. So far so good! My files are ordered in this fashion: - WebContent *(root)* > - ...
16
votes
2answers
19k views

AngularJS passing data to bootstrap modal

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 a problem ...
0
votes
1answer
61 views

Passing a directive to directive via an object in angularjs

Lets say there are 2 directive components 1) List 2) Profile "List" should accept the data in the form of Object notation passed to it through the controller and display the HTML or Directive ...
3
votes
3answers
375 views

Did I share state correctly outside angular directive? (parent scope / $rootScope issue)

I have two elements on my page which are not nested in some way. With attributes on the first one, I would like to set the content of the second one, like so: <body> <input info="This is ...
23
votes
3answers
22k views

How to share the $scope variable of one controller with another in AngularJS?

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 ...
0
votes
4answers
41 views

how angular directive bind controller's service data

controller: service.checkSub(function(data){ $scope.showSub = data.subscribe? false : true; }) directive: app.directive('showSub', function() { return { restrict: 'E', ...
0
votes
1answer
36 views

Simple AngularJS Controller Demo Not Working

I have been using AngularJS for some time now and this particular code block is not difficult by any means, but it's not working and there must be something extremely simple that I am missing here: &...
0
votes
0answers
27 views

Change element style before and after BootstrapModal action

I'm new in Angular and I want to know that is there a possibility to change <div> style using directive. Here is the function that is in controller: $scope.importData = function () { ...
0
votes
1answer
15 views

Combining Nearly Identical Controllers

In my angular application, I have two tables, each with their own controllers. These two tables use ng-repeat to present information retrived from a REST API. The controllers for these two tables ...
1
vote
1answer
38 views

Where should I place code to be used across components/controllers for an AngularJS app?

Should it be associated with the app module? Should it be a component or just a controller? Basically what I am trying to achieve is a common layout across all pages within which I can place or remove ...
0
votes
0answers
20 views

What happens when you do not use $destroy() after creating an instance using $new() when unit testing AngularJS

I was looking for ways to unit test AngularJs when using the "controller as vm" style. I came across this (Karma jasmine and angular controller using 'Controller as' syntax (this instead of $...
20
votes
3answers
37k views

AngularJS: open a new browser window, yet still retain scope and controller, and services

I'm writing an angularJS app. In this particular controller, I open a new browser window through the $window.open service. But in the new window, all the $scope variables are lost. I tried to use ...
0
votes
2answers
48 views

AngularJS, Catch a response from a service and use it in a controller

I have created a service and I have a responce, but I don't know how to use that responce into a controller. The service that I have: angular .module('MyApp') .service('telForm', function($http){ ...
-1
votes
1answer
18 views

How do I use this format of JSON in ng-repeat

This is the JSON and controllers im using: JSON Format: {"networks":[{"longName":"lo"},{"longName":"eth0"}]} Factory: app.factory('networkFactory', [ '$http', ...
0
votes
0answers
35 views

Removing a AngularJS component from the DOM and from his parent on click

i'm trying to show a list of users in AngularJS Each one would be user with a custom component element The components would have TWO buttons First one have to remove the component element from the ...
0
votes
3answers
46 views

How to isolate child controller scope from parent controller scope without changing the view?

Click on the parent button change also child but child button not. I need to change this behavior isolating scopes whith any hacks or other way. Child controller doesn't inherit from parent ...
1
vote
2answers
30 views

AngularJS - Data is not populating in table while using http service

I have a Web API which retrieves list of employees. Now when I call to $http service, I can get data from WebApi but it neither populated in table nor gives any error. Note: I am using angular v1.5....
1
vote
1answer
35 views

How can I call the function in controller from service

I would like to ask if is posible call function getItems(); in ItemController controller(It loads list of data) from fileUpload service(after upload image) - exaple bellow. After upload I want to ...
18
votes
2answers
19k 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, ...
0
votes
1answer
32 views

Change in controller not reflected in view

I have 2 controllers based on the action taken in one controller, I need to update the data in the other. This is my code Controller 1 $rootScope.$broadcast('PackageIns', $scope.pkgtoLoad); ...
2
votes
2answers
46 views

share data between controllers getting/setting data asynchronously from a service - AngularJS

I'm having trouble with getting my custom angular service to work. My service is as follows: app.service('userService', function(){ var user = []; var setUser = function(newObj){ user.push(...
4
votes
1answer
2k views

Service functions outside Angularjs scope

I have created a service in angularJS that uses btford.socket-io module to interact with the server. Since in the service I have implemented some API that I use inside angular at the moment, but for ...
0
votes
1answer
49 views

Argument 'myController' is not a function, got undefined

I'm trying to setup some controllers in my angular app but I'm not sure why I can't make them working, since I think I'm using similar approach as I've done before. I declared app.js file: 'use ...
2
votes
2answers
70 views

Issues with AngularJS Controller

I have the following setup in my html file:: <body> <nav ng-controller="loginCtrl"> <div> <li>Apple</li> <li>Mango</li> ...
0
votes
3answers
62 views

cannot access angular service from external js file

this is my html: <html> <head> <link rel="stylesheet" type="text/css" href="css/style.css"> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"&...
0
votes
1answer
48 views

get scope from a certain controller in angularjs

I try to test my angularjs app through QUnit framework. On the page mysite.ru/#/unittest/ - I use a controller called UnittestCtrl. But in my app I have a DetailCtrl and other page that I want to test....
1
vote
1answer
44 views

Angular: Not able to access variables in controller using service

I am trying to share a variable between a controller and a function. But i get an error from the controller, saying this: TypeError: Cannot read property 'getSet' of undefined I have gone through ...
2
votes
1answer
50 views

Angularjs TypeError: UserService.getCurrentUser.then is not a function at m.$scope.getCurrentUserId

I have an Angular controller and an Angular service. From my controller, I'm calling to the service.There are two functions in my Service. First function works fine. But this problem occurs with the ...
0
votes
2answers
958 views

angular JS service is null inside the controller

This is my first learning project for angular js. i have created a controller(EditEventsController) and a service(eventData). Code for the EditEventController is 'user strict' eventsApp.controller("...
12
votes
3answers
27k views

Check if value exists in the array (AngularJS)

Currently I'm using the forEach()-method of angular to check the new value with the array of objects. But that's the wrong approach because for example in the list are 20 objects. When I'm creating an ...