Note that there are some explanatory texts on larger screens.

plurals
  1. POAngular tries to use/access a function (assigned to this) which hasn't been used within directive's return object
    primarykey
    data
    text
    <p>Here is the exact directive I am using:</p> <pre><code>'use strict'; angular.module('App') .directive('aView', function ($stateParams) { this.link = function(scope, template, directiveAttrs){ template.addClass(scope.elem.classes); } return { template: '&lt;div ng-transclude&gt;&lt;/div&gt;', restrict: 'E', replace: true, scope: {elem: '='}, compile: function(template){ return function(scope, template, directiveAttrs){ template.addClass(scope.elem.classes); } } } }); </code></pre> <p>This gives me the following error:</p> <pre><code>TypeError: Cannot set property 'link' of undefined at http://localhost:9000/scripts/directives/aView.js:5:15 at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:2990:25) at http://localhost:9000/bower_components/angular/angular.js:3894:43 at Array.forEach (native) at forEach (http://localhost:9000/bower_components/angular/angular.js:130:11) at Object.&lt;anonymous&gt; (http://localhost:9000/bower_components/angular/angular.js:3892:13) at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:3000:28) at http://localhost:9000/bower_components/angular/angular.js:2838:37 at Object.getService [as get] (http://localhost:9000/bower_components/angular/angular.js:2960:39) at addDirective (http://localhost:9000/bower_components/angular/angular.js:4609:51) </code></pre> <p>The weird thing about this one is that nowhere within the returned configuration object of this directive do I reference the this.link() function. Also why am I getting undefined? My directive is almost exact copy of agghead's lesson 25.</p> <p>Now, if I comment out this.link() function, a set of errors appears:</p> <pre><code>10 x : TypeError: undefined is not a function at new ngDirective.controller (http://localhost:9000/bower_components/angular/angular.js:14357:5) at invoke (http://localhost:9000/bower_components/angular/angular.js:3000:28) at Object.instantiate (http://localhost:9000/bower_components/angular/angular.js:3012:23) at http://localhost:9000/bower_components/angular/angular.js:4981:24 at http://localhost:9000/bower_components/angular/angular.js:4560:17 at forEach (http://localhost:9000/bower_components/angular/angular.js:137:20) at nodeLinkFn (http://localhost:9000/bower_components/angular/angular.js:4545:11) at compositeLinkFn (http://localhost:9000/bower_components/angular/angular.js:4191:15) at compositeLinkFn (http://localhost:9000/bower_components/angular/angular.js:4194:13) at publicLinkFn (http://localhost:9000/bower_components/angular/angular.js:4096:30) angular.js:5930 Error: 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations: [a lot of code here]... ...debug.watchPerf[watchStr].calls += 1;\n return ret;\n }; newVal: undefined; oldVal: undefined"]] at Error (&lt;anonymous&gt;) at Object.Scope.$digest (http://localhost:9000/bower_components/angular/angular.js:8126:19) at Object.$delegate.__proto__.$digest (&lt;anonymous&gt;:844:31) at Object.Scope.$apply (http://localhost:9000/bower_components/angular/angular.js:8304:24) at Object.$delegate.__proto__.$apply (&lt;anonymous&gt;:855:30) at http://localhost:9000/bower_components/angular/angular.js:9669:36 at completeOutstandingRequest (http://localhost:9000/bower_components/angular/angular.js:3139:10) at http://localhost:9000/bower_components/angular/angular.js:3433:7 </code></pre> <p>What is going on? Has there mysteriously a dependency on my this.link function appeared within angular?<br> <strong>BTW</strong>, it does not matter what this function is named, errors still appear with a different name as reference.<br> <strong>BTW2</strong>, My stack is: yeoman (Grunt as the local server), angular.js, angular.ui.bootstrap, angular.ui.router, Firebase, angularFire. Project is made with yo angular generator.<br> <strong>BTW3</strong>, before I started to tinker with this directive, the one originally generated with yo angular:directive had a <em>link: function postLink(scope, element, attrs)</em> if this matters.<br> Appreciate you time,<br> Jared</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.
    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