Wednesday 15 February 2012

AngularJS: Access factory from within decorator -



AngularJS: Access factory from within decorator -

i extending 3rd party directive using decorator. access 1 of factories within decorator. how can this?

$provide.decorator( 'multiselectdirective', function( $delegate ) { var directive = $delegate[0], link = directive.link; // wipe out shitty template directive.template = ''; // create new template! directive.templateurl = 'app/partials/filters.template.html'; // hook compile phase of directive directive.compile = function( ) { // function returned compile new link function homecoming function( $scope, el, attrs ) { // run original link function. link.apply(this, arguments); $scope.filterclicked = function( buttonname, selection ) { handlefilterclick( buttonname, selection, jiradata, greygooseapi ); } } }; homecoming $delegate; });

i figured out. able inject dependencies in next way:

$provide.decorator( 'multiselectdirective', [ '$delegate', 'jiradata', 'greygooseapi', function( $delegate, jiradata, greygooseapi ) { var directive = $delegate[0], link = directive.link; // wipe out shitty template directive.template = ''; // create new template! directive.templateurl = 'app/partials/filters.template.html'; // hook compile phase of directive directive.compile = function( ) { // function returned compile new link function homecoming function( $scope, el, attrs ) { // run original link function. link.apply(this, arguments); $scope.filterclicked = function( buttonname, selection ) { handlefilterclick( buttonname, selection, jiradata, greygooseapi ); } } }; homecoming $delegate; }]); });

angularjs decorator

No comments:

Post a Comment