ng-view不起作用

时间:2016-12-21 19:03:00

标签: html angularjs

我无法运行以下代码。我尝试了很多东西,包括:$locationprovider.html5mode(true)(以及我的index.html中的一个元素。)

使用此代码,我的网址中会显示/#!/index#%2Ffishes(我的基础)。使用html5mode,我会得到#fishes,但视图不会改变。

Plunkr: http://plnkr.co/edit/a2lkCuxMf0ll9e9QAyiv?p=preview

指数:

<body  ng-app="VissenApp">
    <div class="AngularWrapper">
        <div ng-view>
        </div>
    </div>
</body>

App.js:

var app = angular.module("VissenApp", ["ngRoute"]);
app.config(function($routeProvider,$locationProvider) {
    $locationProvider.html5Mode(true);
    $locationProvider.hashPrefix('!');
    $routeProvider
    .when("/index", {
        templateUrl : "landing.html",
    controller: "fishesController"
    })
    .when("/fishes", {
        templateUrl : "fishes.html",
        controller: "fishesController"
    })
    .otherwise({
        templateUrl : "landing.html",
controller : "fishesController"
    });

}); 
app.controller('fishesController', function($scope,$location) {
    $scope.toFishes = function () {
        $location.path("/fishes");
    };
}); 

Fishes.html

<div class="container-fluid">
    <div class="jumbotron">
    gfhhgfh
    </div>
</div>

landing.html上

<div class="container-fluid landing_background">
    <div  id="landing_logowrapper" >
            <div  ng-click="toFishes()" id="landing_logobackground" > 
                </div>
    </div>
</div>

0 个答案:

没有答案