angularjs-ng-repeat

Get ng-repeat complete in angular directive

感情迁移 提交于 2019-12-05 22:29:46
In the code below, how does the angular directive 'myscroll' know what ng-repeat elements are being created? <myscroll> <div ng-repeat="a in arr">{{a}}</div> </myscroll> I know that the $last event is not fired to the parent directive, how can I solve this? myapp.directive("myscroll", function () { return{ restrict: "E", transclude: true, template: "<span class='left'></span><div class='mask' ng-transclude></div><span class='right'></span>", link: function (scope, element, attr) { scope.$watch("$last",function(){ console.log("ng-repeat rendered") }) } } }) A simple way to do it is to create a

ng-repeat inserting empty anchor tags

假如想象 提交于 2019-12-05 21:27:34
I'm trying to create a menu using angular. A menu item can have children requiring another ng-repeat to print the sub nav items. I'm noticing some strange behavior when attempting to insert an anchor tag within the 2nd ng-repeat. Link to fiddle: http://jsfiddle.net/npU7t/ <li ng-repeat="sub_menu_item in menu_item.sub_menu"> <a href=""> {{ sub_menu_item.title }} </a> </li> With { title: 'menu item with children', sub_menu: [ { title: '<-- empty anchor tag???' } ] } Results in <li ng-repeat="sub_menu_item in menu_item.sub_menu" class="ng-scope"> <a href=""></a> <a href="" class="ng-binding"><--

Does ngRepeat rerender all items after adding an new item?

巧了我就是萌 提交于 2019-12-05 20:09:26
问题 If during execution an item is added to an array that is rendered using ngRepeat , does it redraw all items? 回答1: Since Angular 1.2 we have the 'track by' option which will prevent the repeater from re-rendering all the items. Example: ng-repeat="task in tasks track by task.id" Check out this explanation : http://www.codelord.net/2014/04/15/improving-ng-repeat-performance-with-track-by/ 回答2: Yes, all items are redrawn. In fact, the items may be redrawn at other times as well. Example: When a

Angularjs : sorting shows different result in chrome and firefox browser

﹥>﹥吖頭↗ 提交于 2019-12-05 19:27:16
HI I am getting different result in chrome and firefox browser of sorting of data. Firefox shows correct one. HTML : <table class="datatable"> <thead> <tr> <th width="5%" class="Rank">Rank <a ng-click="sort_by('Rank')"><i class="icon-sort" ng-show="pagedItems[currentPage].length > 1"></i></a></th> <th width="10%" class="Interviews">Interviews <a ng-click="sort_by('Interviews')"><i class="icon-sort" ng-show="pagedItems[currentPage].length > 1"></i></a></th> <th width="25%" class="Dealership">Dealership <a ng-click="sort_by('Dealership')"><i class="icon-sort" ng-show="pagedItems[currentPage]

Detect when a custom filter has completed in AngularJS [duplicate]

≯℡__Kan透↙ 提交于 2019-12-05 19:25:26
This question already has answers here : Calling a function when ng-repeat has finished (10 answers) trigger function after ng-repeat (1 answer) Closed 5 years ago . I have a custom filter function I'm calling for ng-repeat directive: <div ng-repeat="app in appVm.appList | filter:appVm.assetFilter">{{app.title}}</div> This obviously hits my assetFilter function for each app in the appList. When filtering is complete, I want to run another function. How can I detect when the filtering pass has completed? Update Based on responses pointing me towards other answers , I can clarify a bit further.

AngularJS: ng-repeat with key value - updating object

余生长醉 提交于 2019-12-05 16:55:45
问题 I am rendering key:value object array with ng-repeat like this: <div ng-controller="mainCtrl"> <div ng-repeat="record in records"> <div ng-repeat="(key, value) in record"> <input ng-model="key" />: <input ng-model="value" /> </div> </div> </div> JS: var mainCtrl = function($scope){ $scope.records = [ {'key1':'val1'}, {'key2':'val2'} ]; } Problem is that keys and values cannot be updated through input tags. For some reason it becomes one way binding after making ng-repeat iterate over (key

Bind event to child element of directive in link function

南楼画角 提交于 2019-12-05 16:53:11
Need to bind an event to directive's children which is prepared with ng-repeat in templateUrl. I am trying to bind the event in link function but the children are not yet prepared. Here is the plunker. Here I want to bind click event on li tag which are prepared with ng-repeat.But by the time, the link is executed, the li elements are not yet prepared. Can somebody please help. I've resolved the same problem with the angular $timeout link: function (scope, element) { $timeout(function () { element.on('click', '#Id', function () { console.log('inside event handler of the first child) }) }) }

How to make dynamically bound AngularJS models within nested ng-repeat not throw an error until the model is supplied data from somewhere else?

倖福魔咒の 提交于 2019-12-05 14:53:35
The Problem jsFiddle Demonstrating the problem http://jsfiddle.net/7sfaB/ I have a situation I've run into in using AngularJS where I'm building a set of nested <ul> using ng-repeat with a nested ng-repeat from a config service that contains the structure of the lists. Within this nested ng-repeat , I am attempting to use a single complex model object by building the model dynamically based on properties within the config service and binding to an input field. (e.g. ng-model="data[category.id][item.id].notes" ) Here is the HTML template: <ul> <li id="{{category.id}}" ng-repeat="category in

AngularJS: Setting a variable in a ng-repeat generated scope

╄→尐↘猪︶ㄣ 提交于 2019-12-05 13:51:11
问题 How do I access the set of scopes generated by an ng-repeat? I suppose at the heart of this is the fact that I don't understand quite how the relationship works between a) the collection of objects that I pass into the ng-repeat directive and b) the collection of scopes that it generates. I can play around with (a), which the ng-repeat scope watches and picks up, but how do I set variables on the scope itself (b)? My use case is that I have a set of elements repeating using ng-repeat, each of

How to use Angular to create n printable pages?

和自甴很熟 提交于 2019-12-05 13:17:55
Well, I've searched a bit and did not find anything similar. I want to know how can I use Angular to create printable content, jump to the end of the page and print more content. How can I force the content to always fit on a specific size, like a PDF? Do I need Angular to do this? If not HTML, can I iterate over PDF printable pages? Example: Suppose I'm a teacher and I've asked my students to send a 10 lines essays to a specific web system. Now, in the admin page, I want to print 10 students essays on 10 pages, every one of them starting on line 0 of the respective page. Example 2: Suppose I