小编Dar*_*n P的帖子

使用ui路由器在angularjs中重定向页面时如何传递参数?

我试图通过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..
})
Run Code Online (Sandbox Code Playgroud)

我可以将页面重定向到second.html,但我似乎无法获取传递给我的secondCtrl的参数.任何人都可以帮我吗?

谢谢.

javascript angularjs angular-ui

14
推荐指数
2
解决办法
3万
查看次数

我怎样才能在AngularJS中听取点击并保持?

我做了一个时间,让你通过点击按钮增加或减少时间.但是,当我点击并按住按钮时,我希望时间的价值会继续攀升.

所以目前如果你看到我的Plunkr每次单击向上按钮时值都会增加,但是我想这样,所以当我按下按钮时,值会增加,1,2,3,4,5,6,7,8直到我释放按钮.

我怎么能做到这样的事情?

javascript angularjs angularjs-directive

12
推荐指数
1
解决办法
2万
查看次数