6

I have a state router as such:

$stateProvider
  .state('home', {
    url: '/',
    templateUrl: 'spa/layouts/home.html',
    controller: 'HomeController',
    controllerAs: 'ctrl'
  });

In my home.html template I have:

<div class="row main-body">
  <aside class="col-md-2 sidebarNav">
    <div>...</div>
  </aside>

  <section class="col-md-10 main-container">
    <div>..</div>

    <my-list list-items={{ ctrl.listItems }}></my-list>
  </section>
</div>

In the directive my-list I have the following:

var templateUrl = 'spa/components/classList/classList.html';

angular
  .module('directives')
  .directive('myList', component);

function component() {
  return {
    templateUrl: templateUrl,
    controller: classListDir,
    contollerAs: '$ctrl',
    scope: {
      listItems: '@'
    },
    bindToController: true,
  };
}

classListDir.$inject = ['$scope'];

function classListDir($scope) {
  var $ctrl = this;
  console.log($ctrl);
}

I have read and re-read https://docs.angularjs.org/error/$compile/noident?p0=myList. I think my case deals with the second

//OKAY, because the directive uses the controllerAs property to override

// the controller identifier.

I still keep getting the error message. I don't understand the binding with identifier error. Can someone please explain this.

1 Answer 1

15

Found the issue:

contollerAs: '$ctrl'

was misspelled.

Sign up to request clarification or add additional context in comments.

1 Comment

For me it was that I was missing the controllerAs property all together.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.