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
Post a Comment