0

请有人告诉我为什么视图没有被插入到 ng-view 占位符中?我正在使用带有 HomeController 的标准 Visual Studio MVC 项目模板,并且我的所有 .cshtml 文件都在 /Views/Home 中

我正在浏览http://localhost:12345/Home/Example04#/view1

我看到了 Example04 标头,但没有看到 _View01.cshtml 的内容

这是呈现的html:

<!DOCTYPE html>
<html ng-app="movieApp">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>Example04</title>
    <link href="/Content/site.css" rel="stylesheet"/>
    <script src="/Scripts/modernizr-2.5.3.js"></script>
</head>
<body>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>

<h2>Example04</h2>

<div>
    <div ng-view=""></div>
</div>

<script>
    var movieApp = angular.module('movieApp', []);

    movieApp.config(function($routeProvider) {
        $routeProvider
            .when('/view1', {
                controller: 'MovieController',
                templateUrl: '_View1.cshtml'
            })
            .when('/view2', {
                controller: 'MovieController',
                templateUrl: '_View2.cshtml'
            })
            .otherwise({ redirectTo: 'view1' });
    });

    movieApp.controller('MovieController', function ($scope) {
        $scope.movieStars = [
            { name: 'Bruce Willis', character: 'John McClane' },
            { name: 'Sigourney Weaver', character: 'Ripley' },
            { name: 'Tom Cruise', character: 'Ethan Hunt' },
            { name: 'Harrison Ford', character: 'Indiana Jones' }
        ];
    });
</script>
    <script src="/Scripts/jquery-1.7.1.js"></script>
</body>
</html>
4

0 回答 0