angularjs-ng-repeat

AngularJS Group By Directive without External Dependencies

╄→гoц情女王★ 提交于 2019-11-27 00:28:12
I'm new to Angular and would like to learn the best way to handle a problem. My goal is to have a reusable means to create group by headers. I created a solution which works, but I think this should be a directive instead of a scope function within my controller, but I'm not sure how to accomplish this, or if a directive is even the right way to go. Any inputs would be greatly appreciated. See my current approach working on jsFiddle In the HTML it's a simple list using ng-repeat where I call my newGrouping() function on ng-show. The function passes a reference to the full list, the field I

In Angular, how to pass JSON object/array into directive?

允我心安 提交于 2019-11-26 23:57:59
问题 Currently, my app has a controller that takes in a JSON file then iterates through them using "ng-repeat". This is all working great, but I also have a directive that needs to iterate through the same JSON file. This is posing a problem as I cannot request the same JSON file twice on one page (nor would I want to because it would be inefficient). Both the directive and controller request and iterate through the JSON data just fine if I change the filename of one of the JSON files. What I'm

Access index of the parent ng-repeat from child ng-repeat

笑着哭i 提交于 2019-11-26 23:41:48
I want to use the index of the parent list (foos) as an argument to a function call in the child list (foos.bars). I found a post where someone recommends using $parent.$index, but $index is not a property of $parent . How can I access the index of the parent ng-repeat ? <div ng-repeat="f in foos"> <div> <div ng-repeat="b in foos.bars"> <a ng-click="addSomething($parent.$index)">Add Something</a> </div> </div> </div> My example code was correct and the issue was something else in my actual code. Still, I know it was difficult to find examples of this so I'm answering it in case someone else is

How To bind data using TypeScript Controller & Angular Js

放肆的年华 提交于 2019-11-26 23:11:43
I am Playing around with Type Script.I have convert my angular js controller to Type Script But i m facing problem in ng-repeater. (I have attached my controller code below:- class CustomCtrl{ public customer; public ticket; public services; public cust_File; public ticket_file; public service_file; static $inject = ['$scope', '$http', '$templateCache']; constructor ( private $http, private $templateCache ){} Radim Köhler I decided to add another answer describing more details how to create and use controller in TypeScript and inject it into angularJS . This is extension of this Answer How can

Angularjs if-then-else construction in expression

北城以北 提交于 2019-11-26 22:35:00
问题 Can I somehow use if-then-else construction (ternary-operator) in angularjs expression, for example I have function $scope.isExists(item) that has to return bool value. I want something like this, <div ng-repeater="item in items"> <div>{{item.description}}</div> <div>{{isExists(item) ? 'available' : 'oh no, you don't have it'}}</div> </div> I know that I can use function that returns string, I'm interesting in possibility of using if-then-else construction into expression. Thanks. 回答1:

AngularJS : ng-repeat filter when value is greater than

隐身守侯 提交于 2019-11-26 22:32:41
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/1951 12 stamps Mr Adam Blue Date of Birth 28/10/1998 0 stamps Mr Adam Brown Date of Birth 25/9/2010 0 stamps

Show hidden div on ng-click within ng-repeat

自古美人都是妖i 提交于 2019-11-26 22:29:46
问题 I'm working on an Angular.js app that filters through a json file of medical procedures. I'd like to show the details of each procedure when the name of the procedure is clicked (on the same page) using ng-click. This is what I have so far, with the .procedure-details div set to display:none: <ul class="procedures"> <li ng-repeat="procedure in procedures | filter:query | orderBy:orderProp"> <h4><a href="#" ng-click="?">{{procedure.definition}}</a></h4> <div class="procedure-details"> <p

ng-init in ng-repeat shows only the last item info

守給你的承諾、 提交于 2019-11-26 21:58:22
问题 I want to loop through items like this: <section class="col-sm-4" data-ng-controller="PredictionsController" data-ng-init="findMyPredictions()"> <div class="games"> <div class="game-row" ng-repeat="prediction in predictions" ng-init="getGame(prediction.game_id)"> <a class="button primary alt block" href="#!/predictions/{{prediction._id}}"> <span class="home flag {{gameInfo.team1_key}}"></span> <span class="middle"> <span class="date">{{gameInfo.play_at | date: 'd.MM HH:mm'}}</span> <span

Angular orderBy Date

独自空忆成欢 提交于 2019-11-26 21:57:28
问题 I have an array which I want to order by date in Angular.js: <tr ng-repeat="er in vm.readerFeeds | orderBy:'-publishedDate'"> <td>{{er.publishedDate}}</td> </tr> The list ist not ordered right. I think the date format is the cause? Date format is: Sat, 09 Nov 2013 04:26:55 -0800 回答1: To make to orderBy to work you need wrap string date with object of new Date(/**/) in controller. For example: $scope.vm.readerFeeds = [ { //..... publishedDate: new Date(/*your string date*/); }, { //.....

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

天涯浪子 提交于 2019-11-26 21:33:40
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> Try this: <ul> <li ng-repeat="(key,val) in data">{{key}}: {{val}}</li> </ul> darkyndy The problem with documentation is that it says (key, value) with that space ... it took me some time to figure out that because of