suchen

Heim  >  Fragen und Antworten  >  Hauptteil

angular.js - angularjs 模块注入错误

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

为情所困为情所困2743 Tage vor625

Antworte allen(1)Ich werde antworten

  • 滿天的星座

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

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

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

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

    Antwort
    0
  • StornierenAntwort