Angular ui-router $ state.go如何只刷新子状态

时间:2015-12-02 17:42:25

标签: javascript angularjs angular-ui-router

我在ui-router上遇到问题,我有2个状态,一个叫做“lbe”,另一个叫“main”,这是一个“lbe”的子状态。在应用程序中,有一个按钮,我正在尝试做的只是刷新子状态,即“主”状态,并且不会重新加载父状态“lbe”下的所有视图。

以下是一些示例代码:

“lbe”状态:

.state('lbe', {
    abstract: true,
    reloadOnSearch: false,
    url: '/?customerId&routeId&startMp&endMp&currentLayers',
    onEnter: function(){
      //debugger;
    },
    params: {
      customerId: '1',
      routeId: '1333',
      startMp: '380',
      endMp: null,
      currentLayers: []
    },
    resolve: appResolverProvider.lbe,
    views: {
       //.....
    }
  });

“主要”状态:

.state('main', {
    parent: 'lbe',
    url: 'lbe',
    onEnter: function($rootScope, $stateParams){
      $rootScope.$broadcast('foo', $stateParams);
      //debugger;
    },
    views: {
      //...
    }
 });

$ state.go:

 $state.go('main', {
     routeId: routeID,
     startMp: startMP,
     endMp: endMP,
     currentLayers: commonService.getLayerParams(lrsFeatureClassSymbologySqs)
 });

当前问题是当$ state.go被触发时,“lbe”和“main”都被重新加载,但是,我只想重新加载“main”。

由于

修改

这是html代码:

 <button type="button" class="btn btn-primary" data-ng-click="getRoutelogData(main.routeID, main.startMP, main.endMP)">Go</button>

“getRouteLog”功能:

 $scope.getRoutelogData = function(routeID, startMP, endMP) {
                $state.go('main', {
                    routeId: routeID,
                    startMp: startMP,
                    endMp: endMP,
                    currentLayers: commonService.getLayerParams(lrsFeatureClassSymbologySqs)
                });


    };

0 个答案:

没有答案