My directive:
ppm.directive('focusMe', function($timeout) {
return {
link: function(scope, element, attrs) {
scope.$watch(attrs.focusMe, function(value) {
if(value === true) {
console.log('value=',value);
//$timeout(function() {
element[0].focus();
scope[attrs.focusMe] = false;
//});
}
});
}
};
});
Sometimes the directive is called and sometimes not. It could be in the same HTML file where some elements can have the tag and for some element the directive is called and for others it is not.
focus-me="true"
I even have two different HTML files with the same code, but for one of them the directive is never called. For example this code could work in one HTML file and not in another.
<div class="row form-group">
<div class="col-xs-12" style="text-align:center;">
<button class="btn btn-default" ng-click="addMore();" tabindex="5" focus-me="true">
<span class="glyphicon glyphicon-plus button-add"></span>
Add more
</button>
</div>
</div>
What could be causing this? Does the controllers do anything with the directives? It feels weird that