使用 angularjs 动态 url 路由

编程入门 行业动态 更新时间:2024-10-08 22:45:38
本文介绍了使用 angularjs 动态 url 路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我的代码中有类似的东西

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,例如/bmw 或/mercedes,并且所有 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 的值="nofollow">$routeParams

And then in the controller you can get the value of :carId using the $routeParams

这篇关于使用 angularjs 动态 url 路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-21 17:10:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1007781.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路由   动态   angularjs   url

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!