【发布时间】:2014-08-14 01:02:42
【问题描述】:
我正在尝试通过 ui-router state.go 传递参数
但是,我不确定如何传递参数。这是我的代码
app.config(function($stateProvider) {
$stateProvider
.state('first', {
url: '/first',
templateUrl: 'first.html'
})
.state('second', {
url: '/second',
templateUrl: 'second.html'
})
})
//my first.html
app.controller.('firstCtrl' ,["$scope", "$state", function($scope, $state){
$scope.userInput <- come from user
$scope.clickThis=function() {
$state.go("second", $scope.userInput);
}
}]);
//my second.html
app.controller.('secondCtrl,["$scope", "$state", function($scope, $state){
//How do I get the parameter that is passed to here..
})
我可以将页面重定向到 second.html,但我似乎无法获得传递给我的 secondCtrl 的参数。 谁能帮帮我?
谢谢。
【问题讨论】:
标签: javascript angularjs angular-ui