angularjs-ng-repeat

nested ng-repeat $parent.$index and $index

*爱你&永不变心* 提交于 2019-12-03 01:05:49
I have a strange bug that, unfortunately, I cannot replicate with jsfiddle. I've commented out my entire code (Except libraries,etc) except for the following snippets. Is there something obvious that I don't understand? Any ideas? This works and prints: (0,0) (0,1) (1,0) (1,1) <div ng-repeat="i in list"> <div ng-repeat="j in list2"> <div> ({{$parent.$index}} {{$index}}) </div> </div> </div> However, this piece of code prints: (0,0) (1,1) (0,0) (1,1) <div ng-repeat="i in list"> <div ng-repeat="j in list2"> <div ng-if="1"> ({{$parent.$index}} {{$index}}) </div> </div> </div> My controller is:

AngularJS - multiple ng-click - event bubbling

耗尽温柔 提交于 2019-12-03 00:57:13
In the following example: <li ng-repeat="item in items" ng-click="showItem(item)"> <h3>{{item.title}}</h3> <button ng-click="remove(item)">Remove</button> </li> When I click on the button showItem() also is invoked due to event bubbling. I know that I can use $event to watch for $event.currentTarget and do $event.stopPropagation() etc. but this is very ugly. Btw. I don't want to stop propagation on the button (In my case the button is a twitter bootstrap dopdown/button - this is just an example) How do I stop showItem() from beeing called when I click on the remove button? EDIT The ugly fix

AngularJS : How to pass data from directive to controllers function

冷暖自知 提交于 2019-12-03 00:45:31
I'm trying to pass some data from directive into a function addTrackFromPicker in my controller. $scope.addTrackFromPicker = function (message) { console.log("addTrackFromPicker", message); }; Here what I have in my directive dir.directive('youtubeList', function($http, $timeout, YT_event){ return { restrict: 'E', scope: { search: '=', dial: '&' }, templateUrl: 'youtube-list.html', ... Here I want to call controllers function from my template and pass it item.id.$t as argument: <div class="media list-group-item" ng-repeat="item in entries"> <a type="button" ng-click="dial(item.id.$t)"> <img ng

Can't trigger animation on nested ngRepeat

浪子不回头ぞ 提交于 2019-12-03 00:38:52
I can't figure out how to trigger animations on a nested ngRepeat with Angular. The CSS class ".test" is animated. When using ".test" on the inner ngRepeat it doesn't work ( Plunker ): <div ng-repeat="section in sections"> <div ng-repeat="item in section.items" class="test"> <h2>{{item.title}}</h2> </div> </div> When using ".test" on the outer ngRepeat it does work ( Plunker ): <div ng-repeat="section in sections"> <div ng-repeat="item in section.items" class="test"> <h2>{{item.title}}</h2> </div> </div> You probably need to add ngAnimateChildren attribute on the parent container, and update

How to avoid refreshing ng-repeat DOM list when array is updated

陌路散爱 提交于 2019-12-03 00:25:32
I'm building a front-end to a mail-system. It's nicely split up in controllers and services. I'm using $interval to check for new mails, which gets received in JSON, and added to a model. Everything gets rendered nicely to the screen with checkboxes to choose mails for deletions and buttons etc... The problem is, that while a person is making choices - $interval will check for new mails, and replace the model-array with the incoming data, recreating the DOM and resetting all choices no matter if it contains new or the same data. The whole idea of the front-end is to avoid a user clicking

AngularJS - Format Text Return From JSON To Title Case

允我心安 提交于 2019-12-02 23:25:58
I have a service that retrieves data from a JSON file. Some of the data within the data is all in uppercase, for example: $scope.FootballClubs = [{ CompanyName: [MANCHESTER UNITED, LIVERPOOL FOOTBALL CLUB, CHELSEA, WIGAN UNTIED, LEICESTER CITY] }]; And in my HTML, i am simply throwing about the above: <div ng-repeat="name in FootballClubs"> {{ name.CompanyName }} </div> Which throws out: MANCHESTER UNITED LIVERPOOL FOOTBALL CLUB CHELSEA WIGAN UNTIED LEICESTER CITY What i am trying to display is: Manchester United Liverpool Football Club Chelsea Wigan United Leicester City dubadub A filter is

orderBy two fields (one in reverse)

大城市里の小女人 提交于 2019-12-02 23:18:55
I would like to order a friend list by status (online firsts, offline lasts) and by alphabetical order. All I manage to get is: Online firsts / Reversed alphabetical order Or offline firsts / Alphabetical order Here is plunker to expose my problem Change the orderBy filter to this: orderBy:['-status','name'] This will order by descending status (by prefixing the - character), then ascending name. Currently you're passing true to reverse the sort, which is causing the status to be correct (online first), but the names to be reversed (i.e., descending). If you want to keep the reverse boolean,

how to display sorted data from complete object in angular js?

一笑奈何 提交于 2019-12-02 22:33:57
问题 I am trying to make demo of sorted data and display on table.Actually In my demo I am hitting a service got some data (2000) objects in that as a response.So I am display 50 objects at one time and using infinite scroll I load more data which is working fine .I am able to load more data when I scroll to bottom .There is buutton on my header "^" or "V" .Please check on header (left icon "V") Example "Account Name "V"" Using this I icon I need to sort my column . Actually The issue is current

controller connect to directive for validation

陌路散爱 提交于 2019-12-02 21:39:15
问题 Hi I was wondering how I can combine both a directive and controller function for validating a form? Right now I'm validating a form separately with a directive, which highlights a field purple if someone doesn't fill out the field and in my controller I repeat the same validation in order to see whether the user can proceed to saving the data. directive.js .directive('highlightOnError', function() { return { restrict: 'A', require: 'ngModel', link: function(scope, element, attrs, ngModel) {

Angular.js filters and functions on scope that is changing every second

故事扮演 提交于 2019-12-02 21:33:31
问题 The problem. I have a table of entries( $scope.entries ), each row(ng-repeat) with 5 columns, 2 of those columns have custom made filter for various transformations. Now in the same scope I have active_entry( $scope.active_entry ), which is changing every seconds, because of it and how angular works(I guess), the whole scope is being constantly checked and my filters executed. This causes Watch Expressions in Batarang to go sky high over the time. How can I use create some sort of isolated