Guest User

Untitled

a guest
Oct 10th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. angular.module('angularDemo.searchDirective',[])
  2. .directive('searchDirective', searchDirective);
  3.  
  4. function searchDirective() {
  5. function link(scope, elem, attrs) {
  6. elem.bind("keydown keypress", function (event) {
  7. event.preventDefault();
  8. console.log(elem);
  9. console.log(attrs);
  10. scope.$apply(function (){
  11. scope.$eval(attrs.ngEnter);
  12. });
  13. });
  14. }
  15.  
  16. return {
  17. restrict: 'E',
  18. scope: {
  19. tags: '=',
  20. onChange: '=',
  21. onPressEnter: '='
  22. },
  23. template: '<input type="text" ng-model="value" />',
  24. link: link
  25. };
  26. }
Advertisement
Add Comment
Please, Sign In to add comment