javascript - Injection error -
i have module in separate file :
(function () { var staffgrid = angular.module('staffgrid'); staffgrid.directive('employee2', function () { homecoming { restrict:'e', template:"tralala2"}; }); })
in main js file add together dependency:
(function () { var app = angular.module('teamstaffapp', ['staffgrid' ]);
in html (staffgrid.js has been loaded( checked)):
<script type="text/javascript" src="app/staffgrid.js"></script>
and have got error : https://docs.angularjs.org/error/$injector/modulerr?p0=teamstaffapp&p1=undefined
what wrong? stuck without injection staffgrid - works
to declare new module staffgrid
need provide dependencies array sec parameter, otherwise it's getter syntax:
var staffgrid = angular.module('staffgrid', []);
javascript angularjs angularjs-directive
No comments:
Post a Comment