ng视图未显示数据

l0oc07j2  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(145)

我正在学习英语。我正在尝试学习单页应用程序,但ng view并没有显示任何数据。控制台中没有错误。
我的主页:

<!DOCTYPE html>
<html ng-app="RouteApp">
<head>
    <meta charset="utf-8" />
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.28//angular-route.min.js"></script>
    <script src="JavaScript.js"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <title></title>
</head>
<body>

    <nav class="navbar navbar-expand-lg navbar-light bg-light">
        <div class="container-fluid">

                <a class="navbar-brand" href="#!">AnjularJS</a>

            <div class="nav navbar-nav navbar-right">
                <a class="nav-link" href="#/First">First Page</a>
                <a class="nav-link" href="#/Second">Second Page</a>
            </div>
        </div>
    </nav>

    <div class="container">
        <div ng-view>

        </div>
    </div>
</body>
</html>

first.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <h1>This is first!</h1>
</body>
</html>

second.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <h1>This is second!</h1>
</body>
</html>

控制器

var RouteApp = angular.module('RouteApp', ['ngRoute']);

RouteApp.config(function ($routeProvider) {
    $routeProvider.when('First', {
        templateUrl: 'First.html',
        controller : 'CtrFive'
    })
        .when('Second', {
            templateUrl: 'Second.html',
            controller: 'CtrSix'
        })
});

RouteApp.controller('CtrFive', ['$scope', function ($scope) {

}]);

RouteApp.controller('CtrSix', ['$scope', function ($scope) {

}]);

我只是想在第三个页面中显示两个简单的html页面。请让我知道我在这个代码中遗漏了什么。非常感谢。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题