Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS change route by ng-click using ui-router

Tags:

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?

like image 595
marcel Avatar asked Oct 14 '13 13:10

marcel


1 Answers

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

like image 193
bendalton Avatar answered Oct 28 '22 02:10

bendalton