angularjs-ng-repeat

using ng-model within nested ng-repeat directives

爱⌒轻易说出口 提交于 2019-11-30 16:34:10
问题 I'm trying to use ng-model "within" a ng-repeat directive that is itself nested in a ng-repeat directive. The following jsfiddle demonstrates my problem and my two attempts to solve it. http://jsfiddle.net/rskLy/4/ My Controller is defined as follows: var mod = angular.module('TestApp', []); mod.controller('TestCtrl', function ($scope) { var machine = {}; machine.noteMatrix = [ [false, false, false], [false, true, false], [false, false, false] ]; $scope.machine = machine; // ... }); 1. <table

how to compare a stringvalue in ng-show inside a customdirective?

时光毁灭记忆、已成空白 提交于 2019-11-30 16:28:09
问题 Trying to use a directive with an ng-show statement in it. Basically it checks against the value of a string which is the status_p1 property in my 'names' jsonarray: ng-show="name.status_p1==working" The directive is defined as this: app.directive('radioButton',function(){ return { restrict: 'E', replace: 'true', template: '<table border="2px">' + '<tr><td>{{name.name}}</td><td>Working</td><td><img src="http://www.iconshock.com/img_jpg/REALVISTA/general/jpg/256/cross_icon.jpg" alt="img1" id=

Protractor - count elements in repeater and print it

倖福魔咒の 提交于 2019-11-30 16:27:50
问题 I'm trying to count the elements in repeater and to print it to console. This is the markup: <div class="col-md-3 ng-scope" ng-repeat="app in userApps" >...< /div> currently I'm counting and comparing: expect(element.all(by.repeater('app in userApps')).count()).toEqual(4); it works, but I want to be able to print it also. I've tried this: var rows = element.all(by.repeater("app in userApps")); var sum = rows.count(); console.log(sum.getText()); but I'm getting: TypeError: Object [object

angularjs ng-repeat ordering string arrays in numerical order

你离开我真会死。 提交于 2019-11-30 16:25:56
I have a list of post with ids like 1,2,3,4,5,6,7,8,9,10,11,12 (json format) The ids are of type String. But I would like to order it according to its numerical order Normal orderBy:'fiche.id' the list is displayed as below. 1,10,11,12,2,3,4,5,6,7,8,9 I would like the output to be of order - 1,2,3,4,5,6,7,8,9,10,11,12 I guess your ids are strings. A simple solution would be use a no. operation inside order by. So instead ofr orderBy:'id' just use orderBy:'id*1' this will consider the id as no. and sort it according to the numerical order. This is all you need - <div ng-repeat="fiche in fiches

Two way binding of contenteditable item inside ng-list

↘锁芯ラ 提交于 2019-11-30 13:54:34
问题 I am looking to update Phone Name in a list of phones using contenteditable attribute. I have tried using ng-change but thats not getting fired. Is there any way I can do this? I have a list of Store.Phones <ul class="store"> <li ng-repeat="Phone in Store.Phones"> <strong contenteditable> {{Phone.Name}}</strong> </li> <ul> So now when I edit Phone name I need to get it updated in the list. I have tried something like this with model pointing to the element. This is not working. <strong ng

Simple One way binding for ng-repeat?

◇◆丶佛笑我妖孽 提交于 2019-11-30 12:31:28
问题 I have read some articles that said ng-repeat would led to poor performance if there is over 2000 items, because there are too many two way binding to watch. I am new to angularjs and have trouble understanding the relationship between ng-repeat and two-way binding: Does ng-repeat (like outputting a list of json objects) necessarily create two way binding? Is there a simple way to do ng-repeat using only one way binding? (preferably do not need external module) 回答1: Like user1843640 mentioned

directive not working inside <tr> that is ng-repeat bound

孤者浪人 提交于 2019-11-30 12:29:04
I have a table where the rows are repeated via ng-repeat . I am trying to create a template that generates columns <td> for each row <tr> app.directive("customtd", function(){ return { restrict: 'E', template: "<td>{{position.Name}}</td><td>{{position.Code}}</td>", replace: true, scope: { position: '=' } } }); <table> <tr ng-repeat="p in positions"> <customtd position="p"></customtd> </tr> </table> The issue is my custom td template is not rendered at all. Here I intend to replace <customtd> with n number of <td> s - which will be decided based on number of properties on my data object, but at

Use svg with angularjs ng-repeat

拥有回忆 提交于 2019-11-30 12:06:34
I am learning angularjs and I am trying use ng-repeat to create an svg graph. I have this html: <svg> <g id="g_{{$index}}" ng-repeat="i in range" ng-cloak> <rect x="{{i / 5}}" y="{{i / 5}}" width="{{i / 5}}" height="{{i / 5}}"></rect> </g> </svg> the 'range' is just a simple array which is defined in controller like this: $scope.range = [100, 200, 300]; the html is working; the rects are rendered on my page. However, Chrome keeps throwing the following error: Error: Invalid value for <rect> attribute height="{{i / 5}}" js/angular.js:1584 JQLiteClone js/angular.js:1584 JQLite.(anonymous

AngularJS ngRepeat update model

廉价感情. 提交于 2019-11-30 11:42:20
I use ng-repeat to render a html table . My controller looks like so: app.controller("fooCtrl", function($scope, WebSocket) { $scope.foo = [ ... ]; WebSocket.start(function(data) { // this is a callback on websocket.onmessage // here is a for loop iterating through $scope.foo objects and updating them }); }); As you can see, I am updating the $scope.foo array periodically. However, my view is constructed like so: <tr ng-repeat="item in foo"> ... </tr> The problem is, when I update foo , it doesn't re-render my table with new data. How would I go about this problem? Did you wrap the update in

Angular filter list without ng-repeat

我的未来我决定 提交于 2019-11-30 11:39:59
问题 Is there any good way of using angular to filter a list WITHOUT ng-repeat? I dont want to use javascript to draw the list at first, but i want to use angular to filter it afterwards. Example: <input type="search" ng-model="search" placeholder="Search for fruits!" /> <ul> <li>Banana</li> <li>Apple</li> <li>Orange</li> </ul> I want to use the search box to filter the existing html. (Please dont give any examples with ng-repeat or jQuery in general) 回答1: You can write a simple directive to