AngularJS change route by ng-click using ui-router

2019-01-18 09:24发布

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

I've tried this:

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

with

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

But it doesn't work. Any ideas?

1条回答
Ridiculous、
2楼-- · 2019-01-18 09:44

Check out the ui-router documentation wiki.

The best solution is to use $state.go(). e.g., $state.go('recorder.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

查看更多
登录 后发表回答