Answer the question
In order to leave comments, you need to log in
How to animate a newly created element in Angularjs without 3rd party libraries?
.directive('editable', function ($compile, $animate) {
return function (scope, element, attr) {
element.on('click', function (event) {
var popup = $compile('<div></div>')(scope)
.css({
position: 'absolute',
left: '50%', top: '50%',
width: '600px', height: '400px',
'margin-left': '-300px', 'margin-top': '-200px',
background: 'black'
});
element.append(popup);
})
}
})
Answer the question
In order to leave comments, you need to log in
First, you need to connect the dependencies of the ngAnimate application module (do not forget to connect the script itself, of course).
Secondly, set transitions in css for elements that need to be animated.
Then the angular itself will understand what to do with it, and if everything is correctly spelled out in the styles, then, as they say, everything will work by itself. You just need to deal with the classes that Angular substitutes for animation (or configure your own in config via $animateProvider).
More here and on google.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question