代码之家  ›  专栏  ›  技术社区  ›  Bahman Parsa Manesh

具有物化角度问题的Angularjs用户界面路由器

  •  0
  • Bahman Parsa Manesh  · 技术社区  · 6 年前

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

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

    script.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

    1 回复  |  直到 6 年前
        1
  •  1
  •   Muhammad Usman    6 年前

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

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

    ["ui.router"], ['ui.materialize'] 但是就像 ["ui.router", "ui.materialize"]

    推荐文章