[AngularJS] Decorator a directive

'use strict'

    .config(function config($provide) {
        $provide.decorator('ndTrackClickDirective', function diective($delegate) {
            /**@ngInject */
            
            $delegate[0].compile = function() {
                // create a new link function
                return function(scope, el, attr) {
                    
                   /* Your code here*/
                };
            };

            // remove the old link function
            delete $delegate[0].link;

            return $delegate;
        });
    });

 

Guess you like

Origin www.cnblogs.com/Answer1215/p/12219312.html