需要在angular UI router中处理动态参数,并相应地加载模板

Need to handle dynamic params in angular UI router, and load templates accordingly

本文关键字:加载 参数 动态 angular UI router 处理      更新时间:2023-09-26

我需要处理动态参数在角ui-router和加载模板也根据,如果有人使用链接来我的网站,他应该能够达到所需的页面。我需要使用它的多个参数,并获得值表单服务器到相关的值。

.state('home', {
url: '/:shop',
views: {
    "mainbox": {
        templateUrl: "app/shop/main.html",
        controller: "shopMainCtrl",
        controllerAs: "shop"
    }
    // xyz.com/wallmart  should be landed here
}
})
.state('course', {
    url: '/:shop/:area',
    views: {
        "mainbox": {
            templateUrl: "app/area/nav.html",
            controller: "areaNavCtrl",
            controllerAs: "areaNav"
        }
        //xyz.com/wallmart/california  should be landed here
    }
})
.state('area.food', {
    url: '/food',
    views: {
        "mainboxcontent": {
            templateUrl: "app/area/food.html",
            controller: "foodMainCtrl",
            controllerAs: "food"
        }//xyz.com/wallmart/california/food  should be landed here
    }
}).state('area.cloths', {
    url: '/cloths',
    views: {
        "mainboxcontent": {
            templateUrl: "app/area/cloths.html",
            controller: "clothsCtrl",
            controllerAs: "cloths"
        }
        //xyz.com/wallmart/california/cloths  should be landed here
    }
})
.state('buy', {
    url: '/:shop/:area/:buy',
    views: {
        "mainbox": {
            templateUrl: "app/buy/buynow.html",
            controller: "buyMainCtrl",
            controllerAs: "buyNow"
        }
        //xyz.com/wallmart/california/iphone  should be landed here
    }
})

https://github.com/angular-ui/ui-router/wiki你可以试试templateProvider