Note that there are some explanatory texts on larger screens.

plurals
  1. POError: No controller in directive
    primarykey
    data
    text
    <p>Folks, I am an AngularJS newbie and I am trying to create a basic HTML hierarchy bound to a model hierarchy using Angular. My top-level module looks like this:</p> <p>angular.module('fooApp', ['ngResource', 'myList']) which is declared as ng-app="fooApp" at the root div for my page.</p> <p>I then have HTML that looks like this in my page:</p> <pre><code>&lt;my-item-list/&gt; </code></pre> <p>I have a second module that looks like this:</p> <pre><code>var myList = angular.module('myList', []); myList.directive('myItemList', function factory() { var directiveDefinitionObject = { priority: 0, templateUrl: '/assets/partials/my-item-list.html', replace: false, transclude: false, restrict: 'E', scope: false, controller: function($scope, $element, $attrs, $transclude) { // No Op $scope.foo = 'bar'; }, compile: function compile(tElement, tAttrs, transclude) { return { pre: function preLink(scope, iElement, iAttrs, controller) { // No Op }, post: function postLink(scope, iElement, iAttrs, controller) { // No OP } } }, link: function postLink(scope, iElement, iAttrs) { // No Op } }; return directiveDefinitionObject; }); </code></pre> <p>The partial HTML template just contains a table and an ng-repeat on a tag. The template renders just fine, but my JavaScript console contains :</p> <pre><code>Error: No controller: myItemList at Error (&lt;anonymous&gt;) at h (http://localhost:9000/assets/javascripts/angular.min.js:41:458) at i (http://localhost:9000/assets/javascripts/angular.min.js:43:415) at http://localhost:9000/assets/javascripts/angular.min.js:48:191 at http://localhost:9000/assets/javascripts/angular.min.js:94:307 at h (http://localhost:9000/assets/javascripts/angular.min.js:78:33) at http://localhost:9000/assets/javascripts/angular.min.js:78:266 at Object.e.$eval (http://localhost:9000/assets/javascripts/angular.min.js:88:347) at Object.e.$digest (http://localhost:9000/assets/javascripts/angular.min.js:86:198) at Object.e.$apply (http://localhost:9000/assets/javascripts/angular.min.js:88:506) &lt;my-item-list&gt; </code></pre> <p>I intend for the nesting to increase (e.g. replace the in the HTML partial template with another directive and I really need to figure out what I'm doing wrong. It feels like I'm doing some kind of newbie mistake. Whenever I add a 'require' attribute to my directive definition, I get the same "no controller" error message, but with the name of whatever I required (even if I try and require ngRepeat or the page's master controller).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload