【问题标题】:Angularjs ui-router with Materialize-angular issueAngularjs ui-router 与 Materialize-angular 问题
【发布时间】:2018-08-16 06:58:47
【问题描述】:

我想同时使用 ui-router 和 angular-materialize,但是当我想添加 angular materialize 模块时,它会在控制台中显示此错误:

错误:[$injector:modulerr] ...

脚本.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中的代码

【问题讨论】:

    标签: javascript angularjs angular-ui-router materialize angularjs-1.7


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-02
      • 1970-01-01
      相关资源
      最近更新 更多