Как передать параметр, когда я перенаправляю страницу в angularjs, используя ui router?
Я пытаюсь передать параметры через 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. Может ли кто-нибудь помочь мне об этом?
Благодарю.