Extend UI select controller (angular)
<p>I'm trying to extend the ui-select (version 0.17.1) to make it refresh on click. There is this example here (<a href="https://jsfiddle.net/betonetotbo/0yfhe7pf/" rel="nofollow">https://jsfiddle.net/betonetotbo/0yfhe7pf/</a>) that I've been using as a starting point.</p>

<p>I want this to happen app-wide so I replaced the ui-select-choices directive html with my own which includes a div button. I also added a decorator to replace the directives controller with a new one which is not yet defined.</p>

<pre><code>myapp.app.config(function(provide) {
    $provide.decorator("uiSelectDirective", [ "$delegate", "uiSelectConfig", "$controller"], function ($delegate, uiSelectConfig, $controller) {
        var directive = $delegate[0];
        // This line throws error Unknown provider
        var $select = $controller('uiSelectCtrl');

        return $delegate;
    }]);
});
</code></pre>

<p>My problem is that I also want to decorate/extend the controller to add the extra functionality throughout the application. I don't want to re-write it in it's entirety so I'm looking for the proper way to extend a controller such as this.</p>

<p>Thanks.</p>