angularjs-controller

Using a child controller from another module

你。 提交于 2019-11-27 02:19:17
问题 I've defined a module and made it the main module for my app using the ng-app directive. I added two controllers to the main app using angular.module('myApp').controller(). One of those controllers has page wide scope whereas the other controller is a child controller. What I'm now trying to do is include a controller that belongs to another module (not the main myApp module), but I can't figure it out. I do not want to globally namespace controllers. Anyone know how to do this? Here is what

AngularJs - Error: 10 $digest() iterations reached. Aborting

a 夏天 提交于 2019-11-27 01:57:51
问题 I am trying to create a Metro Tile type grid with Angular, to achieve this i want each of the tiles to be a different colour. So my plan of action was to create a function that would randomly pick a colour inside a loop (using ng-repeat ). Here is what i have so far.... <div class={{RandomColourClass()}} ng-repeat="stockRecord in GridStockRecords | filter:searchText"> <div > <h6>{{stockRecord.ProductGroupName}}</h6> </div> </div> So as you can see i am setting the class name with a function

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

你说的曾经没有我的故事 提交于 2019-11-27 00:22:58
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 window.parent but this doesn't work. In fact in the new browser window all the app services, controllers, or scopes are not in effect at all, is this true? Is there a way to open a new browser window yet still makes the new window belongs to the same angular app in the old window? I need to have access to some angularJS services and the scope of the controller that open that new window. Is this

angularjs - how to get in the controller the index of an item in a ng-repeat filter based on the value of one of its properties?

删除回忆录丶 提交于 2019-11-26 21:25:27
问题 I use a ng-repeat in my html file to display filtered items: <li ng-repeat="item in (filteredItems = (items | filter:query))"> {{ item.name }} </a> In the controller, I'd like to get the index of an item based on one of his property. Precision: I'd like to get the index in the filtered list and not in the whole list. Here for example, it will be the index of the item witch name is some_item_7 . var app = angular.module('myApp', []); app.controller('MyCtrl', ['$scope', function MyCtrl($scope)

AngularJS : The correct way of binding to a service properties

会有一股神秘感。 提交于 2019-11-26 21:14:01
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 AngularJS. Below I have two examples of how to bind to properties in a service; they both work. The first example uses basic bindings and the second example used $scope.$watch to bind to the service properties Are either of these example preferred when binding to properties in a service or is there another option that I’m not aware of that would be recommended? The premise of these examples is

Error: [ng:areq] from angular controller

邮差的信 提交于 2019-11-26 20:25:43
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 controller: Error: [ng:areq] http://errors.angularjs.org/1.2.12/ng/areq?p0=TransportersController&p1=not%20aNaNunction%2C%20got%20undefined at Error (native) at http://localhost:3000/lib/angular/angular.min.js:6:450 at tb (http://localhost:3000/lib/angular/angular.min.js:18:360) at Pa (http://localhost:3000/lib/angular/angular.min.js:18:447) at http://localhost:3000/lib/angular/angular.min.js:62:17

Accessing inherited scope with Controller As approach

左心房为你撑大大i 提交于 2019-11-26 19:34:14
问题 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($scope){ $scope.name = "Parent"; }) .controller("childCtrl", function($scope){ $scope.childName = "child of " + $scope.name; }); <div ng-controller="parentCtrl"> {{name}} <div ng-controller="childCtrl"> {{childName}} </div> </div> The Controller-As approach seems to be the recommended way to declare

Linking one controller to another to call service on ng-click

两盒软妹~` 提交于 2019-11-26 17:53:22
问题 I have two templates with respective controllers and service files. One template's(fleetListTemplate) controller(fleetListController) loads data from its service file(fleetService) and displays in its view(fleetListTemplate). When this happens, and I click on one of the loaded data from fleetService, I should link fleetListController to fleetSummaryController to get data from its service file (fleetSummaryService) and display in fleetSummaryTemplate view. Can someone please help me with the

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

拈花ヽ惹草 提交于 2019-11-26 09:42:48
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('ChildCtrl', function($scope, $injector) { $injector.invoke(ParentCtrl, this, {$scope: $scope}); }); Example via: Dead link : http://blog.omkarpatil.com/2013/02/controller-inheritance-in-angularjs.html Can also a controller inside a module inherit from a sibling? var app = angular.module('angularjs-starter', []); app.controller('ParentCtrl ', function($scope) { //I'm the sibling, but want to act as

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

a 夏天 提交于 2019-11-26 09:21:29
问题 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 window.parent but this doesn\'t work. In fact in the new browser window all the app services, controllers, or scopes are not in effect at all, is this true? Is there a way to open a new browser window yet still makes the new window belongs to the same angular app in the old window? I need to have