I want to create @keyframes animation CSS in directive function of Angularjs. The problem is that i can't create it before. I need a variable of scope to create this keyframes.
app.directive("myCSSDiv", function() {
var css = "@keyframes myAnimation {";
var nb_msg = ??? // Here i want to get a variable like $scope.nb_msg but i don't know how to get it
if(nb_msg == 2) {
css += "0%, 100% {left: 0px}";
css += "30%, 60% {left: -100px}";
} else if(nb_msg == 3) {
css += "0%, 100% {left: 0px}";
css += "15%, 50% {left: -100px}";
css += "60%, 85% {left: -200px}";
} else if(...) {
...
}
return {
restrict: "E",
template: css
}
});
Any suggestions? Thanks!