Angular ui-router没有实例化,报注入模块错误

Angular ui-router is not instantiated, giving an inject module error

你好,我有一个关于 Angular UI-router 的奇怪问题。我正要更新一个网络应用程序,并想用 Angular 来完成。我听说过很多关于 UI-router 的好消息,但我没有让它工作。我正在按照有关如何设置视图的教程进行操作,但出现错误:Uncaught Error: [$injector:modulerr] Failed to instantiate module fqmApp due to: TypeError: undefined is not a function

我正在使用 cdn 导入 angular 和 ui-路由器。这是我的确切代码:

<!doctype html>

<html ng-app="fqmApp">

    <head>
        <script src="https://code.angularjs.org/1.3.9/angular.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.13/angular-ui-router.min.js"></script>
        <script src="app.js"></script>

    </head>

    <body>


        <div ui-view>


        </div>


        <a ui-sref="state1">State 1</a>
        <a ui-sref="state2">State 2</a>

    </body>

</html>

JS

"use strict"

angular.module("fqmApp", ["ui.router"])

.config(function ($stateProvider, $urlRouterProvider) {

    //For any unmatched url, redirect to /state1
    $urlRouterProvider.otherwhise("/state1");

    //Now set up the states
    $stateProvider
        .state('state1', {
            url: "/state1",
            templateUrl: "partials/state1.html"
        })
        .state('state2', {
            url: "/state2",
            templateUrl: "partials/state2.html"
        });


})

.controller("ctrl", function ($scope) {
    $scope.hello="hello";
})

如果我不包含配置服务代码,一切正常。我没有得到我要去哪里错了。控制器只是一个测试。它工作正常。这可能是一些愚蠢的错误,但我已经看了一个小时或更长时间了。

有人看到问题了吗?提前致谢。

代码的问题是你打错了,应该是otherwise而不是otherwhise改这部分:

$urlRouterProvider.otherwhise("/state1");

在此:

$urlRouterProvider.otherwise("/state1");