Advertisement
Guest User

Untitled

a guest
Sep 5th, 2015
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. var app = angular.module('app', ['ui.bootstrap']);
  2.  
  3. angular.module('app').service('MyService', function() {
  4. this.doStuff = function(date) {
  5. console.log(date);
  6. }
  7. });
  8.  
  9. angular.module('app').config(function($provide) {
  10. $provide.decorator('datepickerDirective', ['$delegate', 'MyService', function($delegate, MyService) {
  11. var directive = $delegate[0];
  12.  
  13. var link = directive.link;
  14.  
  15. directive.compile = function() {
  16. return function(scope, element, attrs, ctrls) {
  17. link.apply(this, arguments);
  18.  
  19. scope.$watch(function() {
  20. return ctrls[0].activeDate.getMonth();
  21. }, function() {
  22. MyService.doStuff(ctrls[0].activeDate);
  23. });
  24. }
  25. };
  26. return $delegate;
  27. }]);
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement