簡體   English   中英

Angular.js路由不起作用

[英]Angular.js route is not working

朋友,我是angular JS的新手,我想使用angular Route,但是當我單擊#/ home時,它給了我一些奇怪的URL http://127.0.0.1:3000/#!/home#%2Fhome

但是默認情況下,否則其他條件正常運行http://127.0.0.1:3000/#!/home

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

    $routeProvider
    .when('/home', {
        templateUrl: 'views/home.html'
    })
    .when('/list', {
        templateUrl: 'Views/listing.html',
        controller: 'mycontroller'
    }).otherwise({
        redirectTo: '/home'
    })
}]);

你可以嘗試

使用$locationProvider

angular.module('myApp', ['ngRoute'])
    .config(['$locationProvider', function($locationProvider) {
           $locationProvider.html5Mode(false);
           $locationProvider.hashPrefix('');
}]);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM