AngularJS 使用 ui-router 通过 ng-click 更改路由 [英] AngularJS change route by ng-click using ui-router

查看:26
本文介绍了AngularJS 使用 ui-router 通过 ng-click 更改路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I change the route.state using ng-click instead of a link applying ui-sref.

我已经试过了:

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

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

但它不起作用.有什么想法吗?

But it doesn't work. Any ideas?

推荐答案

查看 ui-router 文档维基.

Check out the ui-router documentation wiki.

最好的解决方案是使用 $state.go().例如,$state.go('recorder.options')

The best solution is to use $state.go(). e.g., $state.go('recorder.options')

这是文档中特定功能的链接:https://github.com/angular-ui/ui-路由器/维基/快速参考#stategoto--toparams--options

Here's the link to the specific function in the documentation: https://github.com/angular-ui/ui-router/wiki/Quick-Reference#stategoto--toparams--options

这篇关于AngularJS 使用 ui-router 通过 ng-click 更改路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆