Reputation: 843
I want to mimic something that I have done with JQuery
using AngularJS
.
Below is the fiddle for it.
Three things I have done here.
Upvotes: 0
Views: 1638
Reputation: 1126
Try this JSFiddle: https://jsfiddle.net/ubqrah1w/
It uses an angular directive.
.directive('lastColor', function () {
return {
restrict: 'A',
link: function ($scope, $element, $attrs) {
$element.addClass(angular.element($element[0].querySelector('.items:last-child')).attr('data-color'));
}
}
});
Upvotes: 1
Reputation: 2862
This can be done by angular'js directive (re-usable component) moreover angular has jqlite (jQuery library), as below.
directives:
app.directive('dynamicColor',dynamicColor);
dynamicColor.$inject = [];
function dynamicColor(){
return{
restrict:'A',
link:function(scope,element,attrs){
element.css('background-color',attrs.dynamicColor);
}
}
}
https://plnkr.co/edit/Op5fI5oFQku07tkebBcg?p=preview
Upvotes: 1