(Angular) Passing instance of controller to isolate scope

219 views Asked by At

While the code below "works", it definitely feels very wrong. Is there a "best practices" way to refactor? The issue is that I'm passing an instance of the controller into an isolate scope directive

(note: I can't use this in the directive:

controller: 'ViewController', controllerAs: 'viewCtrl',

because I need the same instance of the controller..)

It may just be the case that I didn't set this up correctly in the first place, but curious to know if there is a good way to "refactor" this

UI-Router config:

  .state('someState', {
    url: '/someurl',
    views: {
      '' : {
        templateUrl: '/path/to/template.html',
        controller: 'ViewController',
        controllerAs: 'viewCtrl'
      },

The Directive

        <some-dirctive
          view-ctrl="viewCtrl">
        </some-dirctive>
0

There are 0 answers