Reputation: 1714
I have following code which works fine
directive
payrollWeb.directive('ngEnter', function() {
return function(scope, element, attrs) {
element.bind("keydown keypress", function(event) {
if(event.which === 13) {
scope.$apply(function(){
scope.$eval(attrs.ngEnter);
});
event.preventDefault();
}
});
};
});
View
<input type="password" ng-enter="login()" ng-model="autPass">
But I don;t want to declare my directive with ng prefix as it is not recommended. But as soon as I change it to anything alse it doesn't work.
Ex:
payrollWeb.directive('prEnter', function() {
return function(scope, element, attrs) {
element.bind("keydown keypress", function(event) {
if(event.which === 13) {
scope.$apply(function(){
scope.$eval(attrs.ngEnter);
});
event.preventDefault();
}
});
};
});
and,
<input type="password" pr-enter="login()" ng-model="autPass">
Any clue?
Ish
Upvotes: 0
Views: 248
Reputation: 5729
scope.$eval(attrs.ngEnter);
should be:
scope.$eval(attrs.prEnter);
Upvotes: 2