angularjs - ngRepeat with $scope.$apply creates duplicates in directive -


i have directive puts dynamic data qtip via template. fetching template , using $compile on (excuse coffeescript):

$http.get scope.qtiptemplate, cache: $templatecache .then (html) ->   clone = $compile html.data   generateqtip text: ->     scope.$apply ->       clone scope 

the generateqtip creates new qtip on directive element , puts first argument content property on options object.

what happens though is, every time open qtip, ngrepeat in template produces duplicate lists, limitto filter. example code:

<ul>     <li ng-repeat="person in object.people | limitto:3 track $index">{{person.name}}</li> </ul> 

produces following first time open qtip:

  • john doe
  • jane doe
  • johnny dowy

and on second time:

  • john doe
  • jane doe
  • johnny dowy
  • john doe
  • jane doe
  • johnny dowy

and on third time:

  • john doe
  • jane doe
  • johnny dowy
  • john doe
  • jane doe
  • johnny dowy
  • john doe
  • jane doe
  • johnny dowy

and on, , on.

why happen? ideas? here's full directive code in this link.

not sure why, had move $compile further inside.

$http.get scope.qtiptemplate, cache: $templatecache .then (html) ->   generateqtip text: ->     scope.$apply ->       $compile(html.data)(scope) 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -