码迷,mamicode.com
首页 > 其他好文 > 详细

angular 路由去除#号

时间:2014-06-15 18:28:00      阅读:288      评论:0      收藏:0      [点我收藏+]

标签:class   blog   java   http   get   javascript   

1.  路由启动          $locationProvider.html5Mode(true);

app.js

define([
    ‘angular‘,
    "App/Ctrl/controllers",
    "App/Directive/directive",

    "angularRoute"
], function (angular,controllers,directives,appDirec) {
    var app=angular.module(‘myApp‘, ["ngRoute",controllers.name,directives.name])
    templete="/front/propertyEntrust/view/templete"
   /* /limitSell/add?propertyId=33 */

    app.config([‘$routeProvider‘,"$locationProvider", function ($routeProvider,$locationProvider) {

        $locationProvider.html5Mode(true);

        $routeProvider.when(‘/detail/:Id‘, { //详情页面
            templateUrl: templete+‘/detail.html‘
        });

        $routeProvider.when(‘/rent/add/:propertyId‘, {  //一般出租
            templateUrl: templete+‘/rent.html‘
        });

        $routeProvider.when(‘/rent/edit/:Id‘, {  //一般出租
            templateUrl: templete+‘/rent.html‘
        });

        $routeProvider.when(‘/sale/add/:propertyId‘, {
            templateUrl: templete+‘/sale.html‘
        });
        $routeProvider.when(‘/sale/edit/:propertyId‘, {
            templateUrl: templete+‘/sale.html‘
        });


        $routeProvider.when(‘/exclusiveRent/add/:propertyId‘, { //独家出租
            templateUrl: templete+‘/exclusiveRent.html‘
        });
        $routeProvider.when(‘/exclusiveRent/edit/:Id‘, { //独家出租
            templateUrl: templete+‘/exclusiveRent.html‘
        });




        $routeProvider.when(‘/exclusiveSale/add/:propertyId‘, {
            templateUrl: templete+‘/exclusiveSale.html‘
        });
        $routeProvider.when(‘/exclusiveSale/edit/:Id‘, {
            templateUrl: templete+‘/exclusiveSale.html‘
        });


        $routeProvider.when(‘/limitSell/add/:propertyId‘, { //签赔
            templateUrl: templete+‘/limitSell.html‘
        });
        $routeProvider.when(‘/limitSell/edit/:Id‘, { //签赔
            templateUrl: templete+‘/limitSell.html‘
        });


        $routeProvider.when(‘/err/:propertyId‘, {
            templateUrl: templete+‘/err.html‘
        });
        $routeProvider.otherwise({redirectTo: ‘/rent‘});
    }]);

    return app
});

 

 2. 设置前端路由开始的字段 即服务器路由的最后的字段

        <base href="/index/">   

 

3, 服务器配置  nodejs为例

app.get(‘/fy/propertyEntrustApply/index/*‘, function (req, res) {
    res.render("a", {});
});

/*app.get(‘/property/:id(\\d+)‘, function (req, res) {

 res.render("b",{});
 });*/
app.get(‘/property/:id‘, function (req, res) {

    res.render("b", {});
});

app.get(‘/qmTable‘, function (req, res) {

    res.render("c", {});
});

 如上所示     http://localhost:3000/fy/propertyEntrustApply/index/rent/add/21

/fy/propertyEntrustApply/index/  为服务器路由  指向a.ejs

之后/rent/add/21  就是前端路由了

angular 路由去除#号,布布扣,bubuko.com

angular 路由去除#号

标签:class   blog   java   http   get   javascript   

原文地址:http://www.cnblogs.com/breakdown/p/3785773.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!