相关疑难解决方法(0)

AngularUI Router:在调用子状态时将url params传递给'abstract'状态

我想在调用子状态时访问抽象状态中的url参数($ stateParam).我很想知道如何做到这一点.plunker中的代码也是

$stateProvider
    .state('contacts', {
        abstract: true,

        //my whole point is to get the id=1 here :(

        url: '/contacts/:id',
        templateUrl: function($stateParams){
            console.log("Did i get the child's parameter here? " + $stateParams.id)
            return 'contacts' + $stateParams.id + '.html'; //this will have a ui-view in it which will render its detail.
        }
    })

    .state('contacts.detail', {
        url: '/:id',
        // loaded into ui-view of parent's template
        templateUrl: 'contacts.detail.html',
        controller: function($scope, $stateParams){
          $scope.person = $scope.contacts[$stateParams.id];
        },
        onEnter: function(){
          console.log("enter contacts.detail");
        }
    }) …
Run Code Online (Sandbox Code Playgroud)

angularjs angular-ui angular-ui-bootstrap angular-ui-router

9
推荐指数
1
解决办法
4701
查看次数

如何在ui-router中更改订单?

我有一个cenario,我有一个列表,并想重新排序.我仍然是ui-router的新手,我无法弄清楚如何做到这一点.

我的状态是这样的(决定传递数据):

$stateProvider
    .state('shoppings-view', {
        url: '/shoppings/:id',
        templateUrl: 'shoppings/partial/shoppings-view/shoppings-view.html'
    }).state('shoppings-view.order', {
        url: '/:order',
        templateUrl: 'shoppings/partial/shoppings-view/shoppings-view.html'
    });
Run Code Online (Sandbox Code Playgroud)

在这里我的控制器:

angular.module('shoppings').controller('ShoppingsViewCtrl',function($scope, $stateParams){

    $scope.order = $stateParams.order != undefined ? $stateParams.order : 'id';
}
Run Code Online (Sandbox Code Playgroud)

并使用ng-repeat显示它们的简单视图.问题是:如果我在url:/ shoppings/1并将链接更改为/ shoppings/1/date,则控制器不会被调用,我无法更改订单.那么,我该怎么做呢?

angularjs angular-ui-router

4
推荐指数
1
解决办法
1589
查看次数