Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('angularDemo.searchDirective',[])
- .directive('searchDirective', searchDirective);
- function searchDirective() {
- function link(scope, elem, attrs) {
- elem.bind("keydown keypress", function (event) {
- event.preventDefault();
- console.log(elem);
- console.log(attrs);
- scope.$apply(function (){
- scope.$eval(attrs.ngEnter);
- });
- });
- }
- return {
- restrict: 'E',
- scope: {
- tags: '=',
- onChange: '=',
- onPressEnter: '='
- },
- template: '<input type="text" ng-model="value" />',
- link: link
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment