angularjs中的$state.go
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了angularjs中的$state.go相关的知识,希望对你有一定的参考价值。
路由是这么定义的:
$stateProvider .state(‘page1‘, { url: ‘/page1‘, templateUrl: ‘views/page1.htm‘, controller: ‘page1Ctrl‘ }) .state(‘page2‘, { url: ‘/page2/:type‘, templateUrl: ‘views/page2.htm‘, controller: ‘page2Ctrl‘ });
用ng-href跳转的话,是这么写的:
ng-href="#/page1"
ng-href="#/page2/1"
用$state.go跳转的话,是这么写的:
$state.go("page1");
$state.go("page2",{type:1});
可以对照一下
以上是关于angularjs中的$state.go的主要内容,如果未能解决你的问题,请参考以下文章
AngularJS UI-Router 中 ui-sref 和 $state.go 的区别
使用AngularJS中的UI-Router将状态重定向到默认子状态
在 Angularjs 中 ui-sref 和 $state.go 如何传递单个多个参数和将对象作为参数
Angular ui-router 中 $state.transitionTo() 和 $state.go() 之间的区别