angularjs-ng-repeat

How do I only show an element if nested ng-repeat is not empty?

柔情痞子 提交于 2019-11-30 01:20:02
I have a List of lists, created with a nested ng-repeat. Each outer ng-repeat contains a div with the label of its inner list (eg: "Group A"). I'm now trying to create a way to avoid showing this label if the inner list is empty due to filtering(Applied by an input searchtext) Here is a plunker explaining my issue and my attempted solution : Plnkr Having a 'heavy' function like isGroupEmpty seems extremely cumbersome - Is there any way to do this in a much simpler fashion? I was toying with the idea of moving the label inside the inner ng-repeat and having ng-show="$first" but it doesnt look

Angular filter list without ng-repeat

浪尽此生 提交于 2019-11-30 00:52:49
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) You can write a simple directive to handle show/hide: app.directive('filterList', function($timeout) { return { link: function(scope, element, attrs)

angularjs ng-repeat ordering string arrays in numerical order

醉酒当歌 提交于 2019-11-29 23:34:13
问题 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 回答1: 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

AngularJS: show loading HTML until data is loaded

回眸只為那壹抹淺笑 提交于 2019-11-29 20:43:18
How do I have AngularJS show a loading spinner until the data has finished loading? If my controller has $scope.items = [{name: "One"}] set up statically, and an AJAX loader which populates $scope.items[0]['lateLoader'] = "Hello" , I'd like the spinner to show until the AJAX load is complete, and then populate the bound span with the retrieved data. <ul ng-repeat="item in items"> <li> <p>Always present: {{item.name}}</p> <p>Loads later: <span ng-bind="item.lateLoader"><i class="icon icon-refresh icon-spin"></i></span></p> </li> </ul> This code populates the bound span immediately, and as item

AngularJS: ng-repeat track by $index inside nested loops

偶尔善良 提交于 2019-11-29 20:35:44
I need a second $index for my nested ng-repeat loop. How and where should I put it? AngularJS site says Creating aliases for these properties is possible with ngInit. This may be useful when, for instance, nesting ngRepeats. <div ng-repeat="person in persons track by $index"> <div ng-repeat="something in array track by $index2"> <!-- where to init this and how to manage it?--> If I use $index again, it seems to work but I am not sure this is the right thing? I am sure there is an easy and correct way of doing it, I just wasn't able to find an example. Thanks $index will refer to the index on

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

馋奶兔 提交于 2019-11-29 18:28:36
问题 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>

AngularJS orderby integer field not working properly

假如想象 提交于 2019-11-29 18:25:38
问题 I just took the simplest demo from http://docs.angularjs.org/api/ng.filter:orderBy and just change the value of age to have different number of digit. It stop working as it expected. Its ordering like "string" not as "integer" value. How should i change it so that it order by age like integer value? Plunkr demo is here http://plnkr.co/edit/pzgiIYrki7jUZdVaTMt9?p=preview Codes are: function Ctrl($scope) { $scope.friends = [{name:'John', phone:'555-1212', age:'2352345'}, {name:'Mary', phone:

Use svg with angularjs ng-repeat

痴心易碎 提交于 2019-11-29 17:53:05
问题 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>

ng-repeat causing \"Error: 10 $digest() iterations reached. Aborting! when passing scope to leaflet directive

谁说我不能喝 提交于 2019-11-29 17:41:32
Edited: After some advices i came back to old version of how i wanted handle angular and leaflet, link to fiddler but still is not working, Explanation: It was working with angular-leaflet-directive, but this directive has very bad performance on firefox, to compare leaflet.js self is very good so i thought i will try to make some small directive on my own, maybe somebody has some advices what is wrong and how to fix it? Link to fiddler: fiddler I try to pass result from ng-repeat to leaflet directive, but when i do it, angular start "Error: 10 $digest() iterations reached. Aborting!, there is

A directive to format phone number

前提是你 提交于 2019-11-29 17:24:23
问题 I was wondering how to automatically format a number in an input field using an angularjs directive? When I type in an input field say 6042919283 I want it to be shown as 604-291-9283. Thanks 回答1: You could use UI Utils mask It allows you to define an allowd input format and will handle the validation for you as well as the formatting 回答2: If your phone number is uniform i.e all the number is of digit 10 this one will work app.directive('formatPhone', [ function() { return { require: 'ngModel