Angularjs ui-router with Materialize-angular issue



我想一起使用ui路由器和角度物化,但是当我想添加角度物化模块时,它在控制台中显示此错误:

错误: [$injector:模块rr] ...

脚本.js

var routerApp = angular.module("routerApp", ["ui.router"], ['ui.materialize']);
routerApp.controller('mainCtrl', ["$scope", function ($scope) {
$scope.select = {
value: "Option1",
choices: ["Option1", "I'm an option", "This is materialize", "No, this is Patrick."]
};
routerApp.config(
["$stateProvider", "$urlRouterProvider",
function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/template1");
$stateProvider
.state("template1", {
url: "/template1",
templateUrl: "template1.html",
controller: "tmp1Controller"
})
.state("template2", {
url: "/template2",
templateUrl: "template2.html",
controller: "tmp2Controller"
});
}
]);
routerApp.controller("mainCtrl", ["$scope",
function ($scope) {
}
]);
routerApp.controller("tmp1Controller", ["$scope",
function ($scope) {
}
]);
routerApp.controller("tmp2Controller", ["$scope",
function ($scope) {
}
]);

请告诉我我的错在哪里。这是我在 Plunker 中的代码

问题在于您在模块定义中使用的语法错误。它应该是

var routerApp = angular.module("routerApp", ["ui.router", "ui.materialize"]);

这意味着模块的依赖项被指定为数组的元素作为模块定义的第二个参数,而不是不同的数组,即不是["ui.router"], ['ui.materialize']而是["ui.router", "ui.materialize"]

最新更新