使用angularjs更改URL的外观

时间:2016-10-03 18:05:51

标签: angularjs route-provider

有没有办法在不修改我的文件夹结构的情况下使用angularJS更改网址的外观?

例如,在我的本地代码上。如果我想导航到我的网站,我会使用类似的东西:

http://localhost:8888/myproject/src/#/home/1212341212

最后的数字是url参数。有没有办法改变文件夹结构,你可以输入:

http://localhost:8888/home/1212341212

或者没有办法,我只需要移动我的文件夹结构?

编辑:提供的代码:

$routeProvider
        .when('/home/:tel', {
            templateUrl: 'views/main.html',
            controller: 'mainCtrl'
        })
        .when('/two', {
            templateUrl: 'views/twoOverLay.html',
            controller: 'mainCtrl'
        })
        .when('/moreThanTwo', {
            templateUrl: 'views/moreThanTwoOverlay.html',
            controller: 'mainCtrl'
        })
        .when('/blank', {
            templateUrl: 'views/main1.html',
            controller: 'mainCtrl'
        })

        .otherwise({redirectTo: '/home/1234567150'});

1 个答案:

答案 0 :(得分:0)

//因为您使用的是hashbang模式,所以您需要包含'#'在你的网址。这应该适合你。无需更改文件夹结构。

http://localhost:8888/#/home/1212341212