javascript - AngularJS directives erroring out - Cannot read property 'compile' of undefined -
newbie angularjs , trying create simple directive. code fails typeerror: cannot read property 'compile' of undefined. suggestions appreciated.
js
var xx = angular.module('myapp', []); xx.directive('myfoo', function(){ return { template:'23' }; });
html
<div ng-app="myapp"> <div my-foo></div> </div>
you can find code , error here https://jsfiddle.net/p11qqrxx/15/
it's return statement.
bad:
return {} // returns undefined, return odd , doesn't @ next line
good:
return{ } // returns empty object, open object on same line return
better:
var directive = {}; return directive; // how it, avoid issue.