gpt4 book ai didi

AngularJS 使用 ui-router 通过 ng-click 更改路由

转载 作者:行者123 更新时间:2023-12-03 11:17:14 26 4
gpt4 key购买 nike

如何使用 ng-click 而不是应用 ui-sref 的链接更改 route.state。

我试过这个:

<button ng-click="selectDir(file.fullPath)">set</button>


$scope.selectDir = function(location) {
options.storageLocation = location;
$route.current = 'recorder.options';
}

但它不起作用。有任何想法吗?

最佳答案

查看 ui-router 文档维基。

最好的解决方案是使用 $state.go() .例如,$state.go('recorder.options')
这是文档中特定功能的链接:
https://github.com/angular-ui/ui-router/wiki/Quick-Reference#stategoto--toparams--options

关于AngularJS 使用 ui-router 通过 ng-click 更改路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19361669/

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