search

Home  >  Q&A  >  body text

angular.js - angularjs module injection error

var app = angular.module('myApp', ['ngLoadScript']);
app.config(function($routeProvider, $controllerProvider, $compileProvider, $filterProvider)
{
app.controllerProvider = $controllerProvider;
app.compileProvider = $compileProvider;
app.routeProvider = $routeProvider;
app.filterProvider = $filterProvider;
});
app.controller('mainController', function($scope) { });

The above code is written in myApp.js, why does the Uncaught Error: [$injector:modulerr] error appear when running. I want to save the controllerProvider and use it later. Why is this wrong?

为情所困为情所困2774 days ago651

reply all(1)I'll reply

  • 滿天的星座

    滿天的星座2017-05-15 16:52:34

    That’s not the problem$controllerProvider,而在$routeProvider. Look at this:

    var app = angular.module('myApp', ['ngLoadScript']);
    

    You haven’t introduced itngRoute,却要注入$routeProvider, do you think it can be done?

    reply
    0
  • Cancelreply