Search code examples
javascriptangularjsangularjs-directiveangularjs-scope

Angular Directive - Scope Breaks after adding directive


I am going through this tutorial. https://code.tutsplus.com/tutorials/mastering-angularjs-directives--cms-22511

For some reason when I add my directive.

myPerfectDirective

It breaks the scoped variable that I have above it. My directive does not have a controller in it. Remove this from my html and my scoped variable returns.

  <my-perfect-directive></my-perfect-directive>

Here is a fiddle: https://jsfiddle.net/ciderman/mfesvznv/2/


Solution

  • I believe that you can't add both the template and templateUrl as properties in your directive. You could add one or the other, like this: https://jsfiddle.net/g1wpLe4d/1/.