动态URL路由与angularjs [英] Dynamic url routing with angularjs
本文介绍了动态URL路由与angularjs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有类似的东西在我的code
I have something like that in my code
<ul ng-model="services">
<p ng-repeat="item in items"><b>{{ item.name }}</b>
</p>
我有,例如3项:宝马,高尔夫,奔驰
我想有每个项目的名称的URL,例如/宝马或/奔驰和所有的URL使用details.html以显示所选项目的细节。
我想知道我怎么能做到这一点。
I have for example 3 items: BMW, golf and mercedes I want to have an url with the name of each item, like /bmw or /mercedes and all url use details.html to show the details of the selected Item. I'm trying to understand how can I do this.
推荐答案
您可以编写
.when('/car/:carId', {
templateUrl: 'some/path/details.html',
controller: 'someCtrl'
})
然后在控制器,你可以得到的值:carId
使用的 $ routeParams
这篇关于动态URL路由与angularjs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文