angularjs - Angular 1.3.10 Uncaught Error: [$injector:modulerr] -
The app is very short at this time, so this is a basic error I am using the UI-Router Files have been found in:
app.module.js:
'strict experiment'; Angular Module ('app', app); App $ Inject = ['ui.router', 'ngCookies', 'ngSanitize',]; Function app () {} app. Roots. Js:
'Strict Use'; Angular Module ('app'). Config (route); Routes $ Inject = ['$ state provider', '$ urlRouterProvider', '$ locationProvider']; Function root ($ state provider, $ urlRouterProvider, $ locationProvider) {// Remove $ url from $ locationProvider.html5Mode (true); // set $ 404 urlRouterProvider Otherwise ('/ 404'); // Configure the $ state provider .state in the app ('app', {abstract: true, url: '', templateUrl: 'modules / app / app.html', controller: 'AppController'})} app.controller.js:
'Strict Use'; Angular Module ('app'). Controller ('AppController', AppController); AppController $ Injection = ['$ rootscope', '$ radius']; Function AppController ($ rootScope, $ scope) {} I get the above error in the console on page load - what am I missing?
You can call $ injection to app Calling on the variable, which is not present in the global area:
Angular Module ('app', app); App $ Inject = ['ui.router', 'ngCookies', 'ngSanitize',]; Now if you specify your module definition for a variable named app : This works:
var App = angular Module ('app', app); App $ Inject = ['ui.router', 'ngCookies', 'ngSanitize',]; Signature for forward module definition:
angular.module (name, [requirement], [configFn]);
You should again be using a variable called a
var injection = ['ui.router', 'ngCookies', 'ngSanitize',]; Var app = angular Module ('app', injection); Or even better: (explains the global scope)
var app = angular Modules ('app', ['ui.router', 'ngcquis', 'ngasnatize',]); You can now strip out:
App. $ Inject = ['ui.router', 'ngCookies', 'ngSanitize',]; But it is possible that the best practice is to keep your entire global area as clean as possible. Therefore, you do not specify your module in the variable:
angular.module ('app', []); And when you want to add it to the configuration or controllers or instructions etc., you call:
angular.module ('app') . Config (); Angular.module ('application') controller () .; Angular.module ('apps') instructions () .; Or you can restart them together:
Angular. Module ('app'). Config (). Controller () .directory (); Another tip, when you are doing configuration or creating a controller, you do not have to do different injections, just you can do this:
Angular Module ('App'). Config (['$ stateProvider', '$ urlRouterProvider', '$ locationProvider', function ($ state provider, $ urlRouterProvider, $ locationProvider) {.....}]); Bracket notation is required, when you reduce your script, it will not screw your injection, if you do not do the least then you can do without it Are:
angular. Module ('app'). Config (function ($ state provider, $ urlRouterProvider, $ locationProvider) {.....}); I know that your problem has already been solved, just because I thought I should clean some things. Good luck!
Comments
Post a Comment