angularjs-ng-repeat

How to highlight a selected row in ngRepeat?

╄→尐↘猪︶ㄣ 提交于 2019-11-26 15:37:07
问题 I couldn't find something that will help me to solve this simple issue in Angular. All the answers are relevant for navigation bars when a comparison is being made against location path. I've built a dynamic table using list and ngRepeat . When I click a row I'm trying to assign this row a css class, selected, to highlight the fact that this row has been selected by user, and remove the .selected from previously highlighted row. I'm missing the method to bind between the row that been

How can I animate sorting a list with orderBy using ng-repeat with ng-animate?

若如初见. 提交于 2019-11-26 15:19:44
问题 I'm rendering a list of objects using ng-repeat with an orderBy filter like this: <li class="list-item" ng-repeat="item in items | orderBy:predicate:reverse"> My attempts to ng-animate a change in sorting of the list have proven frustrating and aren't worth sharing. I have seen the Yearofmoo example app here. Unfortunately this demonstration is not quite what I'm trying to achieve. I need to animate the X position of a given list item when it is placed in a new order after the orderBy

Why the inputs are not working right with ng-repeat [duplicate]

扶醉桌前 提交于 2019-11-26 14:57:49
问题 This question already has an answer here: What are the nuances of scope prototypal / prototypical inheritance in AngularJS? 3 answers Could someone explain to me why I can't get the current selected radio-button in this simple example. I'm trying to generate dynamically the radio-buttons with an ng-repeat directive and get the current radio-button selected using ng-model. Like this: Template: <div ng-repeat="kind in movieKinds"> <input type="radio" name="movies" ng-value="kind" ng-model=

When not to use &#39;track by $index&#39; in an AngularJS ng-repeat?

不羁岁月 提交于 2019-11-26 14:28:53
问题 I recently got the console error ` Error: [ngRepeat:dupes] duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys... — AngularJS Error Reference - ngRepeat:dupes which I then used 'track by $index' and the issue was solved... But that got me thinking... is there a reason why you wouldn't want to use track by $index in an ng-repeat? I've read SO questions like this one as well as other articles, but it seems like almost all of the articles only talk about

What is `priority` of ng-repeat directive can you change it?

房东的猫 提交于 2019-11-26 13:29:08
问题 Angular Documentation says: - The compilation of the DOM is performed by the call to the $compile() method. The method traverses the DOM and matches the directives. If a match is found it is added to the list of directives associated with the given DOM element. Once all directives for a given DOM element have been identified they are sorted by priority and their compile() functions are executed. The ng-repeat directive I believe has a lower priority than custom directives, in certain use

Filtering an Angular 1.2 ng-repeat with “track by” by a boolean property

夙愿已清 提交于 2019-11-26 13:09:53
问题 I'm trying to filter some list items based on the value of a boolean property, but no matter what I do the entire list is always displayed. A few of the the things I've tried have been so broken that nothing displays, but that's neither here nor there. I can't get my filtering working as desired: $scope.attendees = [ {"firstname":"Steve", "lastname":"Jobs", "arrived":true, "id":1} ,{"firstname":"Michelle", "lastname":"Jobs", "arrived":false, "id":2} ,{"firstname":"Adam", "lastname":"Smith",

passing 2 $index values within nested ng-repeat

两盒软妹~` 提交于 2019-11-26 12:41:02
So I have an ng-repeat nested within another ng-repeat in order to build a nav menu. On each <li> on the inner ng-repeat loop I set an ng-click which calls the relevant controller for that menu item by passing in the $index to let the app know which one we need. However I need to also pass in the $index from the outer ng-repeat so the app knows which section we are in as well as which tutorial. <ul ng-repeat="section in sections"> <li class="section_title {{section.active}}" > {{section.name}} </li> <ul> <li class="tutorial_title {{tutorial.active}}" ng-click="loadFromMenu($index)" ng-repeat=

Using ng-if as a switch inside ng-repeat?

混江龙づ霸主 提交于 2019-11-26 12:06:43
问题 I am working on Angular app. I tried to use ng-if and switch inside ng-repeat but didn\'t succeed. I have data like: **[{\"_id\":\"52fb84fac6b93c152d8b4569\", \"post_id\":\"52fb84fac6b93c152d8b4567\", \"user_id\":\"52df9ab5c6b93c8e2a8b4567\", \"type\":\"hoot\",}, {\"_id\":\"52fb798cc6b93c74298b4568\", \"post_id\":\"52fb798cc6b93c74298b4567\", \"user_id\":\"52df9ab5c6b93c8e2a8b4567\", \"type\":\"story\",}, {\"_id\":\"52fb7977c6b93c5c2c8b456b\", \"post_id\":\"52fb7977c6b93c5c2c8b456a\", \"user

Angular.js ng-repeat across multiple elements

…衆ロ難τιáo~ 提交于 2019-11-26 12:05:15
问题 This question has been partly addressed here: Angular.js ng-repeat across multiple tr's However that is just a work-around really, it doesn\'t actually address the core issue, which is: how can one use ng-repeat across multiple elements without a wrapper? For example, jquery.accordion requires you to repeat an h3 and div element, how could one do this with ng-repeat? 回答1: We now have a proper support for this, please see: AngularJs Commmit with this change you can now do: <table> <tr ng

Angular ng-repeat conditional wrap items in element (group items in ng-repeat)

懵懂的女人 提交于 2019-11-26 11:45:40
I'm trying to group the items in a ng-repeat using a condition. An example condition is to group all elements with the same hour. The data: [ {name: 'AAA', time: '12:05'}, {name: 'BBB', time: '12:10'}, {name: 'CCC', time: '13:20'}, {name: 'DDD', time: '13:30'}, {name: 'EEE', time: '13:40'}, ... ] The 'time' field is actually a timestamp (1399372207) but with the exact time the example output is easier to understand. I am listing these items using ng-repeat: <div ng-repeat="r in data| orderBy:sort:direction"> <p>{{r.name}}</p> </div> also tried with: <div ng-repeat-start="r in data| orderBy