-1
我在操作ng路由功能主义者方面存在重大差距。 这是我想要实现的:我有一个主页面,指向dashboard.html和另一个 buildings.html。 ID,类型,颜色 因此,一个传统的URL会看起来像:ngroute支持多个url参数
/buildings?id=110&type=special&color=red
所以据我了解的角度ngroute我应该有这种结构 建筑物页可以用许多参数,如被称为:
$routeProvider
// route for the main page which will direct to the buildings page
.when('/', {
templateUrl : 'web/pages/dashboard.html',
controller : 'dashboardController',
controllerAs : 'dashboard'
})
// route for the main page which will direct to the buildings page
.when('/buildings/:buildingId/:buildingType/:buildingColor', {
templateUrl : 'web/pages/buildings.html',
controller : 'mainController',
controllerAs : 'buildings'
})
;
});
和URL应该是这样的:
/buildings/110/special/red
我不明白的是如何调用对于只有IDØ建筑物页与类型和颜色? 如果我有7个参数,并且只想触发3个呼叫,我该怎么做?
我使用$ location.path在需要时根据gui事件在页面之间切换,例如: $ location.path('/buildings/'+$scope.id);
谢谢。
我尝试了第三种方法,但无法使用location.path生成url字符串,例如$ location.path('/ buildings /'+ $ scope.multiElement.id)生成:/ building%3FId = 110。看起来像?编码为 – 2014-10-31 16:43:25
这里有两种方法: a)'$ location.url('/ buildings/5?color = red&type = special');' b)'$ location.search('color','red' ).search('type','special')。path('/ buildings/5');' – 2014-10-31 16:47:18
是的,但是如果我打算采用第三种方法,我怎样才能使用角度生成传统的url?也有人说这不被推荐,因为它会使页面重新加载 – 2014-10-31 16:56:00