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
30 views
Angularjs 1.x controller not responding in directive
So I am trying to separate my menu into a directive. I have a very simple controller:
function Menu(){
self = this;
self.tab = '';
self.selectedTab = function(tab){
self.tab=tab;
...
0
votes
0answers
17 views
Duplicate Angular Controller on Same Page
I'm building an app that uses angular to render a d3.js bubble chart that can be manipulated by the user. One of my tasks is to implement a second display that allows the user to have to different ...
0
votes
0answers
17 views
angularjs application - can i include business logic/backend code in my angular controllers written inside javascript file
I am developing a web application with technologies html,angularjs, java, Spring.
My requirement is to create a search page for my application. Please find the demo here
I need to enter the details ...
54
votes
20answers
100k 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 ...
20
votes
3answers
34k 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
2answers
55 views
AngularJS - Displays html tags, how to make it readable
i am using PHP as Modal, and Angularjs as Controller, and to display in front end, I am converting PHP into JSON. It displays like as below shown in Front End. I want to display a readable one with li ...
15
votes
5answers
6k views
AngularJS: Should I convert directive's linking function to a controller?
I heard it's a good practice to use the controllerAs syntax along with bindToController: true in directives that use an isolate scope. References: one, two
Suppose, I have a directive like this:
...
1
vote
1answer
139 views
I am getting Error: [ng:areq] Argument 'nameController' is not a function
I am getting following error
Error: [ng:areq] Argument 'nameController' is not a function, got undefined http://errors.angularjs.org/1.3.7/ng/areq?p0=nameController&p1=not%20a%20function%2C%20got%...
2
votes
4answers
62 views
function is undefined if no module is declared in Angular
I am new in Angular and I am studying controllers. In my code I setup a simple controller access but when I tried to run in my browser I encountered a series of error messages that looks like this:
"...
2
votes
1answer
125 views
Controller and Directive requesting isolated scope on the same element
I have a problem when trying adding ng-intro-options attribute on the element
The Code
var App = angular.module('MyApp', ['infinite-scroll', 'angular-intro']);
App.controller('MyController', ['$...
2
votes
2answers
292 views
Argument 'CustomersController' is not a function, got undefined [duplicate]
i'm new to angular js and i'm following a tutorial and i'm getting this error Argument 'CustomersController' is not a function, got undefined my code looks like this
<!DOCTYPE html>
<html ...
175
votes
8answers
64k 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(...
0
votes
1answer
40 views
Rest Webservice call in AngularJS ( promise )
AngularJS : 1.4.X
Scenario 1: Works fine
Scenario 2: Throws 404 error on line xhr.send(isUndefined(post) ? null : post); in angular.js
I'm trying to add inbuilt angular cache to our existing app, ...
0
votes
2answers
45 views
AngularJS - Factory variable doesn't update in controller
I'm facing a new issue with AngularJS.
Infact, since I need to have a "shared" variable, readable and updatable in 2 controllers, I thought about doing that with a factory injected in both the ...
0
votes
1answer
68 views
AngularJS factory and controller
little problem here, i have a controller which communicate with factories, but how can i pass the factory result to a function? Something i tried:
.controller('testCtrl', ['$scope', 'foo', 'boo', ...
-1
votes
3answers
29 views
angular.module called from separate files, does not find Controller [duplicate]
I am trying to modularize my code and moved controller in a separate file that uses same module. But, it does not load, I made sure the load order is correct.
// app.js
angular.module("app", []);
//...
0
votes
3answers
56 views
My function is not accessing the controller.js [duplicate]
my controller.js file
function ServicesCtrl($scope) {
console.log("Hello From ServicesCtrl");
$scope.message = "Hello";
}
index.html file
<html>
<head>
<title>...
0
votes
0answers
13 views
Share function between controllers with angularjs [duplicate]
I start with angularjs. I would like sharing function between 2 controllers because I want use same datas (json) in differents controllers. I tried to add directive..
app.controller("PostsCtrl", ...
0
votes
1answer
41 views
Angularjs : Call factory twice on same controller [duplicate]
I have the following code which is not working as expected, maybe because I am new on angular :)
I want to re-call the same factory function whenever I append a new record to my database, because ...
4
votes
1answer
675 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
0answers
62 views
AngularJS: ES6 $onInit and $onDestroy doesn't fire
I am currently develop a application with angular1.6. The modules where loaded with oclazyloading and webpack. My controller is like
'use strict';
class ActivityController {
constructor($...
3
votes
1answer
3k views
How to update Directive on State Changes
I have a root state that defines the overall structure of the Angular template. In the root state, I have the sidebar included that has dynamic menus via directive that changes based on the state. ...
1
vote
1answer
43 views
Jasmine testing for function call
I'm new to jasmine testing. How can I test function call in watch function?
Below is my code. I'm confused about usage of spy in jasmine and how can I handle function call inside watcher.
Do I need ...
1
vote
2answers
40 views
Why will always use anonymous function in AngularJS
I see almost tutorial use anonymous function in AngularJS, instead of normal function, like function name(para1) {}. Please see this link: http://www.w3schools.com/angular/tryit.asp?filename=...
2
votes
2answers
84 views
Angularjs Modules - Packaging Directives and Their Controllers
I have the following javascript code and i ran into a issue:
My .js file
angular.module('MyApp',['ngMaterial','ngMessages'])
.controller('MainCtrl',['$mdDialog',function($mdDialog'){
this.openDialog ...
16
votes
5answers
37k views
Calling directive's 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 ...
0
votes
0answers
26 views
angularjs ng-repeat autonumber increment from multiple arrays
I have this ng-repeat:
<div ng-repeat="prop in props">
<div ng-repeat="tenant in prop.Tenants">
<label class="col-md-6 control-label">Tenant {{$index?}} ({{tenant....
2
votes
1answer
42 views
Why are my controllers methods not available?
after a long time I have to concentrate an angular again.
But I fail...
... ng-repeat="n in DataController.getObjects"
myApp.controller('DataController', [function () {
console.log('test 1');
...
0
votes
0answers
195 views
angularjs extend controller
In detail.js
(function (module) {
function DetailController($scope) {
//long codes
}
module.controller('DetailController', DetailController);
})(angular.module('app.main'));
In ...
288
votes
15answers
249k 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 ...
3
votes
1answer
20 views
PassFactory.setNewPass is not a function, factory function not a function
Can't seem to get this factory to work properly.
I'm trying to do the $http requests from a factory.
But I'm getting this error of:
TypeError: PassFactory.setNewPass is not a function
Below is the ...
8
votes
2answers
8k views
Call controller function from service in angularjs
I am using socket.io to enable chat in my app and i am using a service SocketService to perform all the socket stuff. When a message came then i want to trigger a function of a controller from the ...
0
votes
3answers
4k views
AngularJS model of select returns undefined
I'm trying to retrieve the value of the current option of a select, but it returns me undefined (I expect it to return me an object).
Markup:
<div ng-app ng-controller="MyCtrl">
<select ...
1
vote
1answer
70 views
AngularJS - Auto update data from one controller to another
Ctrl 1
$scope.$watch(function () {return svc.getMessage();}, function (messageBody) {
if(messageBody){
var eventName = data.eventName;
var someCtrl = $rootScope.$new();
$...
2
votes
0answers
40 views
AngularJS Help - User / Data driven UI Load data before finishing controller
So I have searched for multiple results online through StackOverflow and haven't really found the answer I am looking for. I am trying put together my main UI page with my AngularJS controller. What I ...
1
vote
2answers
1k 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 ...
2
votes
1answer
22 views
Passing data between angular controllers
Below is the sample code where I am trying to pass/sync the value between the two controllers. For the same in view I have a textbox and two place holders for showing the value of the textbox.
I ...
0
votes
0answers
48 views
AngularJS $http.get print 2 times in console why?
I have one example with http-get for example:
In my app:
function Read() {
return $http.get(server + '/user').then(handleSuccess, handleError('Error read user'));
}
In my controller
...
1
vote
2answers
69 views
Angular: How can I call a controller function from an HTML view using ng-if or another Angular directive
My question is; how can I call a controller function from my view when a condition is met/equates to true, using ng-if or perhaps some other Angular directive?
Something like this:
<div ng-if="...
0
votes
1answer
51 views
Hiding navbar based on current path with AngularJS ($scope vs. controller as syntax)
I'm working with the Inspinia Admin Theme (AngularJS Version) and have the following Problem.
I'm trying to show or hide the navbar based on the current path. The Problem with my first approach (...
0
votes
0answers
42 views
Angular list rendering
I've recently started to use Angular for front-end development to communicate with an API to perform state changes in the UI. I would like to know what is the way to update a front-end component after ...
1
vote
2answers
93 views
Interpolation in Angular JS
I am trying to understand Interpolation concepts in Angular JS and I have written this code. I am trying to enter a text in input box and based on the template in text area tag it should replace the ...
0
votes
2answers
450 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 ...
1
vote
0answers
16 views
AngularJs how to access attributes of objects with numbers in its name? [duplicate]
I have an issue to access object property that has numbers in it's name , below sample code is a response of Pinterest API , i can access each property except the images URL . error raised because of ...
1
vote
3answers
27 views
AngularJS multiple Scope needed for Autocomplete
I have an array structure like this.
[
{
"id": "1",
"name": "John",
"city": "NY"
},
{
"id": "2",
"name": "Gerold",
"city": "LA"
},
{
"id": "3",
"name": "...
1
vote
0answers
28 views
AngularJS - Children component binded value not refreshed in ng-repeat
I have a parent component "transactionList" which get a list of banking transactions from an API and a children component "transactionItem" repeated for each transaction in this list.
I encountered ...
0
votes
3answers
30 views
angularjs 1 manual bootstrap doesnot work
I am new to angularjs.
I tried to create 2 different modules in an single js file and them manually bootstrap one of them to a element. This was suggested in one of the stackoverflow questions. But ...
0
votes
2answers
262 views
Use controllers to: Manipulate DOM
I have a ng-repeat-end-watch directive
.....
return {
restrict: 'A',
link: function (scope, element, attr) {
if (scope.$last === true) {
scope.$evalAsync(...
2
votes
1answer
40 views
AngularJs: Route Provider For Tab?
I am new to AngularJs. I am working in Angular Routing Concept. There are plenty of suggestion and examples are available for Routing and i am researching it. But its not fulfilling my requirement. I ...
0
votes
4answers
326 views
console.log for $scope in angular 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 ...