angular.js - angularjs 模块注入错误
为情所困
为情所困 2017-05-15 16:50:34
0
1
650

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保存下来,之后有用。这么做为什么出错?

为情所困
为情所困

Antworte allen(1)
滿天的星座

问题不在$controllerProvider,而在$routeProvider。你看这:

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

你没有引入ngRoute,却要注入$routeProvider,你觉得能成么?

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage