Heim > Fragen und Antworten > Hauptteil
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) {
});
上面这段代码写在myApp.js中,为什么运行时显示Uncaught Error: [$injector:modulerr] 错误。我想把controllerProvider保存下来,之后有用。这么做为什么出错?
滿天的星座2017-05-15 16:52:34
问题不在$controllerProvider
,而在$routeProvider
。你看这:
var app = angular.module('myApp', ['ngLoadScript']);
你没有引入ngRoute
,却要注入$routeProvider
,你觉得能成么?