gpt4 book ai didi

angularjs - 无法使用 ui-router-extras Sticky State 转换到先前激活的状态

转载 作者:行者123 更新时间:2023-12-01 23:49:52 27 4
gpt4 key购买 nike

根据 http://christopherthielen.github.io/ui-router-extras/#/sticky 使用 ui-router-extras 粘性状态(并行状态)和深层状态重定向,我无法转换到之前激活的状态。

应用程序.js

'use strict';

angular.module( 'StickyStateDemo', [
'ui.router',
'ct.ui.router.extras',
'StickyStateDemo.controllers'
])

.config(function($stateProvider, $stickyStateProvider, $urlRouterProvider) {

var states = [];
$stickyStateProvider.enableDebug(true);

states.push({name: 'contentview', url: '/',
views: {
'@': {controller: 'ContentViewCtrl', templateUrl: 'contentView.tpl.html'}
}});

states.push({name: 'contentview.small', url: 'small/{myId}',
views: {
'smallview@contentview': {controller: 'SmallViewCtrl', templateUrl: 'smallView.tpl.html'}},
deepStateRedirect: true, sticky: true
});

states.push({name: 'contentview.large', url: 'large/{myId}',
views: {
'largeview@contentview': {controller: 'LargeViewCtrl', templateUrl: 'largeView.tpl.html'}},
deepStateRedirect: true, sticky: true
});

angular.forEach(states, function(state) { $stateProvider.state(state); });
$urlRouterProvider.otherwise('/');
})

.run( function run ($rootScope, $state, $stateParams) {
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
});

Controller .js

'use strict';
angular.module('StickyStateDemo.controllers', []);

angular.module('StickyStateDemo.controllers')

.controller('MainCtrl', function ($scope, $state) {
$scope.launchSmallView = function() {
$state.go('contentview.small', {myId: 1});
};

$scope.launchLargeView = function() {
$state.go('contentview.large', {myId: 1});
};
})

.controller('ContentViewCtrl', function ($scope) {
})

.controller('SmallViewCtrl', function ($scope) {
})

.controller('LargeViewCtrl', function ($scope) {
});

Plunker 与整个应用程序:http://plnkr.co/edit/yvtoUle0ZUWkSOmjlCoQ?p=preview第一次可以很好地进入这两种状态,但尝试返回到先前激活的状态将失败。

我可能只是遗漏了一些东西,但我已经在互联网上搜索示例并尝试了多种变体,但我尝试的所有方法都会导致相同的行为。

最佳答案

事实证明这是 ui-router-extras 中的错误:https://github.com/christopherthielen/ui-router-extras/issues/103 .恢复到 ui-router v0.2.11(并将 ui-router-extras 保留在 v0.0.10)是一个临时修复。

更新:此问题已在 ui-router-extras 中修复

关于angularjs - 无法使用 ui-router-extras Sticky State 转换到先前激活的状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27044622/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com