首先,您必须在route中添加参数。
app.config(function($stateProvider) { $stateProvider .state('first', { url: '/first', templateUrl: 'first.html' }) .state('second', { url: '/second/:id', templateUrl: 'second.html' })});
现在添加第一个控制器
app.controller.('firstCtrl' ,["$scope", "$state", function($scope, $state){ $scope.userInput <- come from user $scope.clickThis=function() { $state.go("second", { id: $scope.userInput }); }}]);
在第二个控制器中注入$ stateParams
//my second.htmlapp.controller.('secondCtrl',["$scope", "$state", "$stateParams", function($scope, $state, $stateParams){ $scope.id = $stateParams.id;})
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)