javascript - Problems with ng-repeat and ajax-loaded content in directive -


I'm releasing some instructions that wrap the jCarousel plugin.

Calling Directive in HTML:

 

  & lt; Div class = "jcarousel" date-carousel dates = "dates" & gt; & Lt; / Div & gt;  

Where dates - Dynamically loaded array by AJAX through one of my services

DirectX

Directive template:

  & lt; Ul & gt; & Lt; Li & gt; (Ng-repeat = "dates in dates") {{date.format ("MMM D")}} & lt; / Li & gt; & Lt; / Ul & gt; & Lt; One square = "jcarousel-control-prev" & gt; & Lt; I class = "fa-angel-left" & gt; & Lt; / I & gt; & Lt; / A & gt; & Lt; One class = "jcarousel-control-next" & gt; & Lt; I class = "fa-aeg-right" & gt; & Lt; / I & gt; & Lt; / A & gt;  

Therefore due to the dates is equal to the director inside [] (I think the Ajax load since the instructions Dates are rendered) My JCarusel is not working properly Is anyone able to help me with this issue and can tell me how my instructions work properly and if necessary then reinstate my instructions In order to apply?

I think I've got some decision in my link function I have found to use the $ watchCollection that when date becomes a non-fair array and then calls jCarusel ... maybe it Out of a poor way but it works for me

  link: function ($ scope, $ elements, $ attrs) {return $ scope. $ WatchCollection ('date', function) {var jcarousel; If ($ scope.dates.length) {jcarousel = $ element; Jcarousel.on ("jcarousel: reload jcarousel: create", function () {var width; width = jcarousel.innerWidth () / 3; back jcarousel.jcarousel ("item"). CSS ("width", width + PX ");}). Jcarousel ({wrap: "null"}); $ Element.find (".jcarousel-control-prev") JcarouselControl ({Target: "- = 1"}); $ Element.find (".jcarousel-control-next") JcarouselControl ({Target: "+ = 1"});}}); }  

Is there a better and reasonable solution?


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -