我在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
更多推荐
发布评论