作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
根据 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/
我是一名优秀的程序员,十分优秀!