1

I am using mgcrea.ngStrap and i am trying to change some methods in $select provider. Is there any way to decorate some functions inside this provider?

To be precise here is the code of the provider (i removed all unnecessary methods and data) :

  angular.module('mgcrea.ngStrap.select', [ 'mgcrea.ngStrap.tooltip', 'mgcrea.ngStrap.helpers.parseOptions' ]).provider('$select', function() {
  this.$get = [ '$window', '$document', '$rootScope', '$tooltip', '$timeout', function($window, $document, $rootScope, $tooltip, $timeout) {
    function SelectFactory(element, controller, config) {
      $select.$thisIsMethodIWantToChange = function() {
            ...........
      }
    return SelectFactory;
  } ];
})

Is there any way to change $thisIsMethodIWantToChange method?

i tried something like this

angular.module('mgcrea.ngStrap.select')
    .config(function ($provide) {
        $provide.decorator('$select', function ($delegate) {
            $delegate.$thisIsMethodIWantToChange=function() {
                //do something..
            }
            return $delegate;
        });
    });

but it's not working.

Noémi Salaün
  • 4,866
  • 2
  • 33
  • 37
tony
  • 131
  • 1
  • 1
  • 9

0 Answers0