javascript - AngularJS Directives: Using return in the `pre` function -
i've been trying track down bug in nggridv2.0.14 "gridid" class not being set on nggrid classed element, though dynamic stylesheet being appended document header, , found kind of wierd...
this bug causes columns appear "on top of" each other...
in ng-grid-2.0.14.debug.js there directive created called nggrid (of course!). directive uses suggested "directive definition object" form. define inherited scope defining scope:true , declare compile function returns object structure containing only function pre , does not declare function post.
what weird there return statement within pre function, , cannot find documentation return statements within pre function. function ends in angular's "processqueue", believe deffered.$$state.pending (i tracing call stack find this, not sure). during $digest loop, angular tests these array indexes functions , invokes them.
the nggrid function being called, can found @ ng-grid-2.0.14.debug.js line 3318, lot, , of these things working, such $destroy cleanup logic, $complie($scope) of gridtemplate, event listener establishing, and, most importantly, addition of 2 specific classes our directive's ielement appears still "in scope." part failing.
they adding class ielement by:
ielement.addclass("nggrid").addclass(grid.gridid.tostring()); sometimes works, doesn't...
sometimes element picks classes "ng-scope nggrid ng[0-9]{13}" (e.g: ng-scope nggrid ng1453913625179), , not, when have stepped through function , watched line of code adds classes executed.
further investigation!: if place ng-if="true" on parent node of "nggrid element" (the element instanciates nggrid directive attribute), eveything works!
my question: appending classes element within $digest loop have issues or reason why work , not time? also, can find documentation on setting return values pre? couldn't find return values here. finally, why setting ng-if="true" on parent of ielement fix issue of class names not being appended ielement's class list? thanks!
Comments
Post a Comment