angularjs-ng-repeat

AngularJS : ng-repeat filter when value is greater than

喜夏-厌秋 提交于 2019-11-26 08:23:40
问题 I have a simple ng-repeat that throws out data, one of fields it displays is NumberOfStamps: <tr ng-repeat-start=\"list in Data.Items \"> <td><a href=\" {[{list.Title}]} {[{list.ForeName}]} {[{list.SurName}]}</a></td> <td>(Date of Birth {[{list.Dob}]})</td> <td>{[{list.NumberOfStamps}]} stamps</td> </tr> Example output: Mr Adam Happy Date of Birth 01/6/1984 16 stamps Mr Adam Sad Date of Birth 24/11/1975 0 stamps Mr Adam Green Date of Birth 02/1/1963 1 stamps Mr Adam Red Date of Birth 21/1

AngularJS - How can I reference the property name within an ng-Repeat

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 07:58:18
问题 In addition to rendering the value of the properties in an object, I\'d also like to render the property name as a label. Is there a way to do this with ng-repeat ? For example: <ul> <li ng-repeat=\"option in data\">{{propertyName}}: {{option}}</li> </ul> Which might spit out something like this: <ul> <li>Name: John</li> <li>Phone: (123) 456-7890</li> <li>Country: England</li> </ul> 回答1: Try this: <ul> <li ng-repeat="(key,val) in data">{{key}}: {{val}}</li> </ul> 回答2: The problem with

AngularJS: ng-repeat list is not updated when a model element is spliced from the model array

安稳与你 提交于 2019-11-26 07:24:31
问题 I have two controllers and share data between them with an app.factory function. The first controller adds a widget in the model array (pluginsDisplayed) when a link is clicked. The widget is pushed into the array and this change is reflected into the view (that uses ng-repeat to show the array content): <div ng-repeat=\"pluginD in pluginsDisplayed\"> <div k2plugin pluginname=\"{{pluginD.name}}\" pluginid=\"{{pluginD.id}}\"></div> </div> The widget is built upon three directives, k2plugin,

Directive isolate scope with ng-repeat scope in AngularJS

有些话、适合烂在心里 提交于 2019-11-26 06:53:05
问题 I have a directive with an isolate-scope (so that I can reuse the directive in other places), and when I use this directive with an ng-repeat , it fails to work. I have read all the documentation and Stack Overflow answers on this topic and understand the issues. I believe I have avoided all the usual gotchas. So I understand that my code fails because of the scope created by the ng-repeat directive. My own directive creates an isolate-scope and does a two-way data-binding to an object in the

ngRepeat Filter by deep property

人走茶凉 提交于 2019-11-26 06:35:33
问题 If I have a complex object with objects as property values, how can I filter by one of the nested properties? Can this be done with the OOB ng-repeat filter? Data { Name: \'John Smith\', Manager: { id: 123, Name: \'Bill Lumburg\' } } ngRepeat <li ng-repeat=\"e in emps | filter:Manager.Name\">{{ e.Name }}</li> 回答1: You need to pass in the argument to filter by: <input ng-model="filter.key"> <ul> <li ng-repeat="e in list | filter: {Manager: {Name: filter.key}}"> {{e.Name}} (Manager: {{e.Manager

Preserve line breaks in angularjs

≯℡__Kan透↙ 提交于 2019-11-26 05:57:33
问题 I have seen this SO question. My code instead of ng-bind=\"item.desc\" uses {{item.desc}} because I have a ng-repeat before. So my code: <div ng-repeat=\"item in items\"> {{item.description}} </div> The item description contains \\n for newlines which are not rendered. How can the {{item.description}} display the newlines easily assuming that I have the ng-repeat above? 回答1: Based on @pilau s answer - but with an improvement that even the accepted answer does not have. <div class="angular

Angular - Can&#39;t make ng-repeat orderBy work

倾然丶 夕夏残阳落幕 提交于 2019-11-26 05:27:33
问题 I\'ve tried many examples of ng-repeat with orderBy, but I can\'t make my json work with it. <div ng-app> <script type=\"text/javascript\" src=\"http://code.angularjs.org/1.0.1/angular-1.0.1.js\"></script> <div ng:controller=\"Main\"> <div ng-repeat=\"release in releases| orderBy:\'environment_id\'\"> {{release.environment_id}} </div> </div> </div> And the JSON function Main($scope) { $scope.releases = { \"tvl-c-wbap001 + tvl-webapp\": { \"timestamp\": \" 05:05:53 PM \", \"environment_id\": \

angular ng-repeat in reverse

安稳与你 提交于 2019-11-26 04:36:47
问题 How can i get a reversed array in angular? i\'m trying to use orderBy filter, but it needs a predicate(e.g. \'name\') to sort: <tr ng-repeat=\"friend in friends | orderBy:\'name\':true\"> <td>{{friend.name}}</td> <td>{{friend.phone}}</td> <td>{{friend.age}}</td> <tr> Is there a way to reverse original array, without sorting. like that: <tr ng-repeat=\"friend in friends | orderBy:\'\':true\"> <td>{{friend.name}}</td> <td>{{friend.phone}}</td> <td>{{friend.age}}</td> <tr> 回答1: I would suggest

orderBy multiple fields in Angular

家住魔仙堡 提交于 2019-11-26 04:32:07
问题 How to sort by using multiple fields at same time in angular? fist by group and then by sub-group for Example $scope.divisions = [{\'group\':1,\'sub\':1}, {\'group\':2,\'sub\':10}, {\'group\':1,\'sub\':2},{\'group\':1,\'sub\':20},{\'group\':2,\'sub\':1}, {\'group\':2,\'sub\':11}]; I wanted to display this as group : Sub-group 1 - 1 1 - 2 1 - 20 2 - 1 2 - 10 2 - 11 <select ng-model=\"divs\" ng-options=\"(d.group+\' - \'+d.sub) for d in divisions | orderBy:\'group\' | orderBy:\'sub\'\" /> 回答1:

How to use ng-repeat for dictionaries in AngularJs?

半世苍凉 提交于 2019-11-26 04:05:51
问题 I know that we can easily use ng-repeat for json objects or arrays like: <div ng-repeat=\"user in users\"></div> but how can we use the ng-repeat for dictionaries, for example: var users = null; users[\"182982\"] = \"{...json-object...}\"; users[\"198784\"] = \"{...json-object...}\"; users[\"119827\"] = \"{...json-object...}\"; I want to use that with users dictionary: <div ng-repeat=\"user in users\"></div> Is it possible?. If yes, how can I do it in AngularJs? Example for my question: In C#