Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ngRepeat and directives execution order

When an Angular directive contains an ngRepeat element, the ngRepeat execution appears to to occur after the containing directive's link execution.

Is there a mechanism ($watch, $observe, etc) that I can use to wire up a response after the ngRepeat execution?

Here's an example of the behavior: http://plnkr.co/edit/yBiSvveeSissU7Rik6Kp?p=preview

I want to operate in a state in the directive where the inputs are available.

My primary goal is to alter the elements of ngRepeat from the containing directive.

like image 646
mhcode Avatar asked Apr 19 '13 21:04

mhcode


People also ask

What is the priority level of directives?

Directives are compiled in priority order, from highest to lowest. The default is 0. If set to true then the current priority will be the last set of directives which will execute (any directives at the current priority will still execute as the order of execution on same priority is undefined).

What is ngRepeat?

Definition and Usage. The ng-repeat directive repeats a set of HTML, a given number of times. The set of HTML will be repeated once per item in a collection. The collection must be an array or an object. Note: Each instance of the repetition is given its own scope, which consist of the current item.

Which property tells the directive to stop the compilation of custom directive with a lower priority?

terminal: Used with priority. If set to true, it stops execution of directives with lower priority.

Why ng-repeat is used?

Angular-JS ng-repeat directive is a handy tool to repeat a set of HTML code for a number of times or once per item in a collection of items. ng-repeat is mostly used on arrays and objects.


1 Answers

The typical way to determine when ng-repeat has finished is to write a directive that checks to see if $last is true. Then you can call a function (defined on a parent/ancestor scope) or emit an event, inside a $timeout callback or $evalAsync.

For more details and examples, see Calling a function when ng-repeat has finished

like image 161
Mark Rajcok Avatar answered Sep 22 '22 08:09

Mark Rajcok