无法显示子页面的内容(AngularJS路由)

时间:2017-03-14 17:41:17

标签: javascript html angularjs

当我打开主页时,我无法看到" home.html"的内容。文件。

  

http://127.0.0.1:60590/#/home.html

同样的问题是当我打开" contact.html"

  

http://127.0.0.1:60590/#/contact.html

文件,因为它将我重定向到" home.html"试。

我认为" app.js"代码有效。

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

mainApp.config(['$routeProvider', function($routeProvider){

    $routeProvider
        .when('/home', {
            templateUrl: 'view/home.html'
        })
        .when('/contact', {
            templateUrl: 'view/contact.html'
        }).otherwise({
            redirectTo: '/home.html'
        });
}]);

的index.html



<!DOCTYPE html>
<html lang="pl" ng-app="mainApp">
    <head>
        <meta charset="UTF-8">
        <title>kedar</title>
        <link rel="stylesheet" href="style.css" type="text/css">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
              integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
        <script src="lib\angular-route.min.js"></script>
        <script src="lib\app.js"></script>
        <script src="https://code.jquery.com/jquery-3.1.1.min.js"
                integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
                crossorigin="anonymous"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    </head>
    <body>
        <header ng-include="'header.html'"></header>
        <main ng-view></main>
    </body>
</html>
&#13;
&#13;
&#13;

0 个答案:

没有答案