保存并更新URL时重写清洁名称(Rewriting A Clean Name On Save And Updating The URL)

编程入门 行业动态 更新时间:2024-10-12 18:18:18
保存并更新URL时重写清洁名称(Rewriting A Clean Name On Save And Updating The URL)

我在ui-router的帮助下,使用一个干净的名称模式在URL中表达来自MongoDB的对象。

http://192.168.2.11:8080/games/“2000-risk-global-domination”/

当我使用Angular Resource更新该对象时,我更新了$ scope中的干净名称(并删除了不友好的字符)

$scope.item.clean = ($scope.item.year + '-' + $scope.item.title.split(/[\s:]+/).join('-')).toLowerCase();

我可以使用数据库中的新干净名称正确更新对象...使用新的干净名称更新URL的最佳方法是什么?

使用$ stateParams更新URL?

I am using a clean name pattern to express an object from MongoDB, in the URL, with the help of ui-router.

http://192.168.2.11:8080/games/"2000-risk-global-domination"/

When I update that object using Angular Resource, I have updated the clean name in the $scope (and removed unfriendly characters)

$scope.item.clean = ($scope.item.year + '-' + $scope.item.title.split(/[\s:]+/).join('-')).toLowerCase();

I can properly update the object with the new clean name in the database... What would be the best way to update the URL with the new clean name?

Use $stateParams to update the URL?

最满意答案

目前能够使用$ state.go('backend.edit',{id:$ scope.item.clean}); 其中重新加载路由和数据。

如果有人可以发布更好的方法来更改URL而无需往往DB的往返调用,请告诉我。 谢谢

Currently able to use $state.go('backend.edit', { id: $scope.item.clean }); Which reloads the route and data.

If anyone can post a better way to change the URL without the roundtrip call to the DB, please let me know. Thank you

更多推荐

本文发布于:2023-08-04 02:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1405337.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   清洁   名称   URL   Updating

发布评论

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

>www.elefans.com

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