I'm looking to pass a variable from controller to a directive I have created:
HTML
<div class="dropup inline-block" ng-repeat="event in video.events">
<event video="video"></event>
</div>
DIRECTIVE
.directive("event", function() {
return {
restrict: "E",
replace: true,
scope:{
video: '=videoObject'
},
template: '<a class="btn btn-default event-margin" ng-style="{color: video.iconColor, float: floatEvents}" type="button" data-title="{{event.title}}"><span class="fa fa-fw {{event.icon}}"></span></a>',
link: function(scope, elm, attrs) {
elm
.on('mouseenter', function() {
elm.css('background-color', scope.video.color);
elm.css('color','#FFFFFF');
})
.on('mouseleave', function() {
elm.css('background-color','#FFFFFF');
elm.css('color', scope.video.color);
});
}
};
The problem is when I add scope in the returned dict attribute it stops to work.
So the idea is to change the color of the element when I pass the mouse on the element, with the value of video.color, a variable in the $scope of the controller.
I have been looking for an answer in other posts but they don't work: