AngularJS使用ui路由器通过ng单击更改路由
如何使用ng click而不是应用ui sref的链接来更改route.state 我试过这个:AngularJS使用ui路由器通过ng单击更改路由,angularjs,angular-ui,angular-ui-router,Angularjs,Angular Ui,Angular Ui Router,如何使用ng click而不是应用ui sref的链接来更改route.state 我试过这个: <button ng-click="selectDir(file.fullPath)">set</button> 但它不起作用。有什么想法吗?查看ui路由器文档wiki 最好的解决方案是使用$state.go()。e、 例如,$state.go('recorder.options') 以下是指向文档中特定功能的链接: tyvm,我以前试过。但是忘了注入$state。。所以它
<button ng-click="selectDir(file.fullPath)">set</button>
但它不起作用。有什么想法吗?查看ui路由器文档wiki 最好的解决方案是使用
$state.go()
。e、 例如,$state.go('recorder.options')
以下是指向文档中特定功能的链接:
tyvm,我以前试过。但是忘了注入$state。。所以它不起作用。现在一切都好了。。thx alot:)将
$state
注入所有视图的一种方法是使用angular.module('myApp')。运行(['$rootScope','$state',function($rootScope,$state){$rootScope.$state=$state;}])代码>。请参阅ui sref查看此答案:
$scope.selectDir = function(location) {
options.storageLocation = location;
$route.current = 'recorder.options';
}