1

私は自分のアプリを次のように設定してい$routeProviderます:

angular.module('myApp', [])

    .config(['$routeProvider', function($routeProvider){
        $routeProvider
            .when('/authorisation', { template: 'templates/authorisation.html', controller: AuthenticationController})
            .otherwise('templates/404.html');
    }]);

index.htmlは:

<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
    <title>Gift Cloud Dash</title>
    <script src="lib\angular\angular.js"></script>

    <!-- App config -->
    <script src="js\app.js"></script>

    <!-- Import controllers -->
    <script src="js\controllers\authentication-controller.js"></script>
</head>
<body>
<div>
    <a href="#/authorisation">Authorisation</a>
</div>
<div ng-view></div>
</body>
</html>

インデックス ページを開くとハイパーリンクが表示されますが、クリックするとファイル パスが表示され、<div ng-view></div>.

Angular 表示リソース パス。

4

1 に答える 1

4

修正しました。他の誰かが同じ症状になった場合に備えて、ここに残します。

ルーティング構成の構文が間違っています: 次のようにする必要があります:

angular.module('myApp', [])

    .config(['$routeProvider', function($routeProvider){
        $routeProvider
            .when('/authorisation', { templateUrl: 'templates/authorisation.html', controller: AuthenticationController})
            .otherwise({redirectTo: 'templates/404.html'});
    }]);
于 2013-08-18T20:50:00.583 に答える