gpt4 book ai didi

javascript - $state.go ("Any url and not just a State ")

转载 作者:行者123 更新时间:2023-12-03 08:15:38 24 4
gpt4 key购买 nike

我想写类似 $state.go("/spheres/{{$stateParams.sphereId}}/mono/view"); 的内容使用外部 url 而不是状态,但这不起作用:(

现在我明白为什么这不起作用了,因为 $state 需要一个状态,但是有解决方法吗?

我想使用这个而不是这个的原因:

window.location.replace("/spheres" + $stateParams.sphereId + "/mono/view");
window.location.href = "/spheres/" + $stateParams.sphereId + "/mono/view";

是因为我有一个在链接到下一个 URL 时播放的声音片段,出于某种原因,location & href在链接时停止该原声片段。

讽刺的是,在 <a> 中使用 href标签确实可以在不停用声音片段的情况下工作,但随后我遇到了另一个问题,即无法在移动设备上使用 ng-click 调用 href/ng-href。

最佳答案

假设您已使用名为 sphereId 的参数定义了状态 URL:

state: 'spheres.details.mono.view',
url: '/spheres/:sphereId/mono/view'

您可以通过以下方式进入参数化状态:

$state.go('spheres.details.mono.view', { sphereId: $stateParams.sphereId });

关于javascript - $state.go ("Any url and not just a State "),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33961009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com