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.
1
vote
0answers
22 views
AngularJS get nested json data in ui-router view
I have an application with Miller Columns, i.e. a series of lists. Each column of this is a view.
The data is pulled in from a json file with a resolve in the route.
The first column displays a ...
4
votes
2answers
8k views
Get Current Controller Name in AngularJS
I'm trying to write a directive that will generate a grid. The following code works but I have to specify the controller name 'DemoCtrl'. Is it possible to retrieve the current controller name from ...
1
vote
3answers
30 views
Calling function in child controller from parent controller
I have a controller nested in another controller.
<div ng-controller="manufacturerController" ng-cloak>
<div ng-controller="contractController" ng-cloak>
<div data-ng-if="...
10
votes
2answers
11k views
Assign multiple controller in $stateProvider.state
Probably this is an easy question for advanced angular users, but I did not find this issue somewhere well explained.
So I was restructuring my code, when I realized, I have two controllers in a view,...
0
votes
1answer
28 views
AngularJS: Which is better way to pass parameter to Modal Controller?
I have seen two ways of passing the parameters to the AngularJS Modal, one via resolve binding and another via scope binding. I was wondering if one is better than the other and why?
Resolve Binding
...
0
votes
0answers
34 views
Angular JS - The directive is accessible between controllers
I am new to Angular and just wondering how come my directive is accessible between controller as I only register it into sub controller, not main app controller. Below is my code.
app.module.js
...
0
votes
0answers
28 views
where does the 'ng-model' directive store the data?..I am not able to access it inside a controller
Please help me to get the data from text box to a controller without embedding controller inside element
<html ng-app="mymod">
<head>
<script
src="https://ajax.googleapis.com/...
0
votes
0answers
24 views
Add new Route from Controller
in app.js
i have added
$routeProvider.when('/blank', route.resolve('blank','SEC', 'blankAs', 'vm'))
.when('/New', route.resolve('New','BAR', 'barNewAs', 'vm'));
in controller.
on ...
2
votes
4answers
23k views
How to retrieve the value from textbox using AngularJs?
$scope.add=function()
{
//How to retrieve the value of textbox
}
<input type='text'><button ng-click='add()'></button>
When I ...
0
votes
2answers
52 views
AngularJS - Controller cannot read ng-model object property
I want to make a controller that can be reused by other views.
(This controller will serve as a template)
The problem is that I can't make a simple validation because it can't read the properties ...
147
votes
10answers
94k views
AngularJS : The correct way of binding to a service properties
I’m looking for the best practice of how to bind to a service property in AngularJS.
I have worked through multiple examples to understand how to bind to properties in a service that is created using ...
2
votes
1answer
60 views
Error: [$injector:unpr] Unknown provider: $scope in angular Js when routing
var myWebsite = angular.module('myWebsite', ['ngRoute']);
myWebsite.config(['$scope', '$routeProvider', function($routeProvider) {
$routeProvider
.when("/home", {
templateUrl : "index....
0
votes
0answers
63 views
Angular.js + ui-router wrong controller
I'm using angular 1.6.1 and angular-ui-router 0.3.2.
I have basic routes set-up as follow:
{
state: 'home',
config: {
url: '/home',
templateUrl: '...',
title: 'home'
}
},
{
state:...
177
votes
9answers
67k 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(...
3
votes
2answers
216 views
Refresh the data in controller when scope gets changed in AngularJS
I'm pretty new with angular and I've read a lot of threads here and googled this topic but I cannot get a clear answer. what i am really trying to achieve is. lets suppose I have a controller A, this ...
1
vote
3answers
57 views
how to call angularjs function which is appended in div
$scope.showtbleoption = function(id)
{
console.log(id);
$("#showoption").empty();
$("#showoption").append('<button class="btn btn-info" ng-click="editrc(id)">');
};
how to call ...
0
votes
1answer
35 views
AngularJS component: $doCheck won't run for fake HTTP request with $q.when()
I created Simple Angular textarea component with characters counter, made with $doCheck component hook on Plunker, which counts characters on $doCheck hook. I read that it should run for every digest ...
0
votes
1answer
106 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 ...
4
votes
1answer
2k views
Angular Component: how to specified value for output binding function defined in parent?
I wanted to use Angular 1.5's component to get benefit from its one-way binding: <hero-detail hero="ctrl.hero" save="ctrl.save(hero)"></hero-detail>. But, as Todd Motto points on his blog: ...
3
votes
3answers
8k views
How to check file type before uploading with AngularJS?
I want to upload a zip file to server. Before uploading, I have to check if it's a zip file.
If it's a zip file, then submit.
If it's not a zip file, it comes up "Not a zip file." and the file can't ...
0
votes
2answers
43 views
Why do I need a $watch when using function in controller in combination with a directive
I know and can imagine why I need the commented lines of code to let this work. But I can't found the technical reason. Why is the field not update when you click on the button? (the $watch fixed the ...
0
votes
1answer
46 views
Passing object key as an argument for parameter retrieval
I've built an AngularJS factory:
angular.module('app.services', [])
.factory('StorageService', function($localStorage) {
$localStorage.$default({
objA : ['foo','bar'],
objB : []
...
1
vote
2answers
30 views
Angular: updating view with value passed from directive to controller
Budding web developer here struggling with updating the view from my controller.
I'm using highmaps and angular to build a neat selection tool for my web app. I've got a directive nested inside the ...
9
votes
2answers
8k views
Mocking the event object in AngularJS event unit testing
I have the following test:
it('Should keep location when user rejects confirmation', inject(function ($controller, $rootScope) {
var confirmStub = sinon.stub(),
eventStub = {
...
8
votes
1answer
9k views
Karma testing: TypeError: Attempted to assign to readonly property
When I am trying to unit test my controller I am getting the error.When I debug the testcase's expect I am getting the expected value but its failing with below error.What am I missing here or whether ...
1
vote
2answers
62 views
how to do easiest group of filtering conditions in angularjs?
I have four filtering such as JobType,Experience,DateAdded and Salary i want to do filtering as individual and group. For it i defined a filter as filterType in my controller and added to template ...
0
votes
2answers
41 views
Data share between directive and controller in AngularJS
I need to take a step back and understand the data flow between controllers to directive, directive to controller and the inline template vs template url in directives.
I have customDirective ...
2
votes
0answers
77 views
Trying to understand Angular error message
I am trying to solve a problem happening when injecting an element to a customer website that uses Angular framework.
Edit: Sorry, the page uses Angular (also called Angular2) not just AngularJS.
...
1
vote
2answers
40 views
Update $state variable in 1 module from another
https://plnkr.co/edit/PWuKuVw9Dn9UJy6l8hZv?p=preview
I have 3 modules, routerApp, tickers and tags. Basically trying to rebuild my app out of smaller mini-apps.
The routerApp template contains the 2 ...
0
votes
2answers
28 views
Logic in the controller that isn't assigned directly to the scope should be fulfilled else where before it gets to the controller [duplicate]
$scope.listValueChanged = function (name) {
listId = [];
$scope.listType= name;
};
if ($scope.contacts && $scope.contacts.length > 0) {
var gsSelectedContacts =$scope.contacts;...
0
votes
2answers
229 views
use jQuery.matchHeight from Angular directive
I am trying to set elements to the same height using jQuery.matchHeight. I call the function from an Angular directive
angular.module('myApp')
.directive('matchHeight', ['$timeout', function ($...
0
votes
1answer
43 views
AngularJS Error [$injector:modulerr]
Sorry for big piece of code but I've got a problem with my AngularJS module, created in accordance with these lessons. I want my angular module to work with ASP.NET MVC, but I can't even run it.
(...
1
vote
1answer
48 views
AngularJS controller is not a function, got undefined (data from factory)
I'm refactoring an old AngularJS project so it's less dumb and bad, separating controllers and exporting data with a factory rather than having all the data inside of one giant controller. I can't get ...
-1
votes
2answers
52 views
What is key benefits of using controllerAS in angularJS
ng-controller="invoiceController as invoice" create new invoiceController constructor and assigned the same to scope behind the scene, which the similar thing $scope injection does in controller ...
0
votes
1answer
64 views
$http service in Factory returns undefined in AngularJS
I am new in angularJS and try to make a CRUD operation to clear my concept. I try to use angular factory but I google a lot and unable to find any solution on below concept. I just want to use my ...
0
votes
1answer
48 views
AngulaJS Controller Declaration — Error: $controller:ctrlreg
I have a basic controller in angularJs named "BasicController".
Below is my code (BasicController.js):
(function () {
var app = angular.module("app", []);
app.controller("...
0
votes
2answers
65 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
1answer
65 views
How to inject a Controller into state object inside of Config? (ui-router)
Below I'm trying to inject the PlatformCtrl into my $stateProvider object:
app.js
"use strict";
module.exports = angular.module('tickertags', [
'templateCache',
'headers', // headers ...
0
votes
2answers
34 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;
...
56
votes
20answers
105k 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 ...
22
votes
3answers
40k 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
82 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 ...
16
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
146 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
134 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
472 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 ...
0
votes
1answer
103 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
76 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', ...