5

私はAngularJSのチュートリアルに従っています- 「AngularJSでウェブサイトを構築する」

私が使用しているルートはチュートリアルとほとんど同じです:

// JavaScript Document
angular.module('quest', []).
    config(function($routeProvider) {
        $routeProvider.
            when('/about', {template:'partials/about.html'}).
            when('/start', {template:'partials/start.html'}).
            otherwise({redirectTo:'/home', template:'partials/home.html'});
    });

問題は次のとおりです。リソースのコンテンツではなく、リソースへのパスのみが表示されるため、html コンテンツを表示する代わりに、次のように表示されます。

PARTIALS/ABOUT.HTML

何が間違っているのかわかりませんが、#/about URL に移動すると「PARTIALS/ABOUT.HTML」と表示され、URL を index.html#/start に変更すると「PARTIALS/」と表示されます。 START.HTML"

ページの html:

<!DOCTYPE html>
<html lang="en" ng-app="quest">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <link rel="stylesheet" type="text/css" href="css/index.css" />
        <title></title>
    </head>
    <body ng-controller="MainController">
        <script type="text/javascript" src="js/angular.min.js"></script>
        <script type="text/javascript" src="js/quest.js"></script>

        <div ng-view></div>

    </body>
</html>
4

1 に答える 1

11

templateUrlの代わりに使用template

于 2013-04-01T17:38:37.833 に答える