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.
0
votes
2answers
42 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
33 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">
...
0
votes
1answer
23 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 ...
1
vote
3answers
41 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
21 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 ...
35
votes
15answers
56k 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
20 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
20 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
73 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
266 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 ...
23
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
169 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
279 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
21 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
36 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
34 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
30 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
17 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
11 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
38 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
54 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 ...
219
votes
13answers
161k 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
21 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
54 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
27 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
45 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
20 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?
0
votes
4answers
819 views
Angularjs undefined variable in controller
I have a problem in controller with the properties of object. My factory return one object with another object and one function. I can call the function but i can't access in another object ...
1
vote
2answers
303 views
Angular bind service property to a controller scope
I have 2 controllers using the same service, the first controller change the value of a property on the service, I need the second controller to know the property has changed to set the new value in ...
1
vote
3answers
49 views
How to keep track of current user in angularJS controllers?
factory / service:
angular.module('phoenix-template')
.factory('User', ['$http', function($http){
function current(){
...
0
votes
1answer
32 views
Angularjs directive template = $scope.(some variable from another controller)
This is part of my AngularJS application
.controller('Littlebear',function($scope) {
$scope.spread='<h1>this is the</h1> Littlebear spread.'+
'<img ...
0
votes
1answer
19 views
Sending received Rest data in service file to controller angularjs
I am new to angular js and I have a problem sending the received data from my service file to controller, which ultimately binds to my html. Can someone please help me resolve this problem. Thank you.
...
2
votes
2answers
26 views
Error: [ng:areq] customerController not a function got undefined
I am beginner to angularjs and I am writing a simple application to get started with it. I keep getting this error Error: [ng:areq] customerController not a function got undefined
I have tried to ...
0
votes
1answer
44 views
is it Possible (partial class) concept for controller in angularjs?
Is there any way to do code grouping using partials in angularjs?
Reason --- I have a controller which contains too much code. This controller contains the code For several Methods and a lot of ...
0
votes
4answers
62 views
Why post method not working in angularjs in this example?
Here I created sample for read and update json file. Reading the json file is working properly but I tried to update the json file that it show's Failed to load resource: the server responded with a ...
1
vote
2answers
187 views
How to update an angular directive with async data
I have a controller which gets json data called content.json. When I render the UI, I can't know if the json is available yet. The controller gets the json data asap when the app loads, it is an array ...
0
votes
0answers
25 views
How to create a constructor for controller in angularjs?
Am learning angularjs. I want to now is it possible to create constructor in angular? if it is yes, how to create constructor for controller? can any one help me on this thanks,
6
votes
3answers
6k views
Angularjs Uncaught Error: [$injector:modulerr]
I am learning Angular.js and I am not able to figure out whats wrong with this simple code. It seems to look fine but giving me following error.
**Error**: Uncaught Error: [$injector:modulerr] ...
3
votes
1answer
64 views
How to load dynamic Tabs in ngDialog box in angularjs?
Dynamic Tab Sample File Link -- Not Working
Static Tab Sample File Link -- Working
In NgDialog Tabs Not Showing
In above link I added the sample file for ngDialog model with tabs. In index
...
0
votes
1answer
23 views
How to implement message before redirect in angularjs using ngdialog?
How to create unsave change in angularjs using ngdialog.
Eg: currently we are in page1 some fields we are edited. directly we going to page2 or somewhere that time ngdialog need to popup and ask if ...
1
vote
1answer
61 views
Angular JS: update controller when data change in second controller
what i m doing:
simple html file shows first page , in this page i have one title and button, initially i set $scope.index = 0. so, we set first position of array. when we click on next button it ...
0
votes
1answer
30 views
AngularJS: should I choose what to print in the view or the controller?
I have a user info view where I have a table with some user data, which I get asynchronously from the backend. I don't want to print every field of this object.
What's the better practice, to pick ...
0
votes
1answer
53 views
Able to access `$scope` and `this` using controller as syntax. Why?
I'm building an Angular controller using controller as syntax:
<body ng-controller="ctrl as myCtrl">
<p>accessed via scope resolution: {{ foo }} </p>
<p>accessed via ...
0
votes
1answer
24 views
Angular controller functions are both constructors and a decorators?
If one writes a controller as ctrl for the following code:
function Controller($scope) {
$scope.abc = "123";
}
angularApp.controller("controller", Controller);
Does the pseudo code below ...