using element.AddClass to add an angular js directive, which is restricted to act as a 'class'

angular-ui, angularjs, angularjs-directive

Solution

I guess, Angular is not observing elements, if they get a new directive attached at runtime. To make it work, you should recompile the element after adding the class with $compile.

Something like

element.addClass('myDraggable');
$compile(element)(scope);

regards

Problem

I made a directive in angular js restricted it to act as a class and this directive makes my element drag-able. On mousehover i want to do addClass and add this directive which is supposedly a class, but this doesnt give the desired result, am i missing something? below is what I am doing ``` module.directive('myDraggable', function ($document) { var directiveObject= { restrict:'AC', //logic of dragging } return directiveObject; }); ``` i try to do ``` element.addClass('myDraggable'); // but this fails! pls help ```

Original source