I am very well aware how mixing angularjs and jquery is NOT a good idea. However, I need a custom carousel, which could slide through TEXT ONLY. All the existing carousel animations for angularjs depend heavily on image being part of the content, whereas I have no images. So I found a very good jquery library for such a thing, called "slick".
It works well with angularjs, but when I dynamically ADD new values to an existing array, the whole thing breaks apart. How could I change this part of code so that I could dynamically add objects to array AND keep jquery slick library working?
Here's the code, you can press "prev" and "next" and carousel will work, but as soon as you press ADD NEW ELEMENT button, the whole thing falls apart. http://jsbin.com/tihodihuho/1/edit?html,js,output
You need to make sure that by the time your call the jQuery functions
unslick
andslick
the DOM has already been rendered.You can accomplish that by having those functions inside a
$timeout
function (with delay 0, of course). That will ensure that the code inside the$timeout
function will get executed after the$diggest
cycle has finished.Try this:
Example
UDATE
In order to fix the issue that the OP described in the comments bellow, and that it's completely unrelated with the original question I've came up with this workaround:
Example