亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

angular.js - angualr-ui tabs return to initial value after refresh
僅有的幸福
僅有的幸福 2017-05-15 16:57:42
0
2
801

RT, when using tabs in angular-ui to switch tabs, the current tab selection status will not be recorded. When someone presses refresh, the initial value will be returned. How to record current tab selected state?

僅有的幸福
僅有的幸福

reply all(2)
世界只因有你

I have also encountered the same problem. When I was working on the [Initiation] page of a company's marketing event recently, the initiation was divided into 4 steps. I used each step as a named view, such as: <p ng-if="step == 3" ui-view="step-3"></p>, 通過(guò)ng-if來(lái)確定顯示第幾步, 然后在控制器中有一個(gè)方法來(lái)設(shè)置step. The method is as follows:

$scope.$on('changeStep', function(e, data) {
   $scope.step = data;
});

However, when editing to a certain step, if you refresh the browser, you will return to the first step. At first I used localStorage to store stepstatus

$scope.step = $localStorage.step ? $localStorage.step : '1';
$scope.$on('changeStep', function(e, data) {
   $scope.step = data;
   $localStorage.step = data;
});
// 不在發(fā)起頁(yè)面時(shí)清除數(shù)據(jù)
$scope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
  if (toState.name != 'app.xx.new' || toState.name != 'app.xx.edit' || toState.name != 'app.xx.view') {
    delete $localStorage.step;
  }
})

This way you can save the state, but there is a problem. If the current editing reaches step 3, and I reopen a window to enter editing from the list page, it will go directly to the third step, skipping the first two steps.
I also tried it later$cacheFactory, 一刷新狀態(tài)就丟失了,所以最后的解決辦法是使用sessionStorage. You can read the article localstorage by community array_huang to understand the usage scenarios of the two.

This method is not necessarily the best, but it can be tried as an alternative.

漂亮男人

Refer to angular cache factory

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template