Javascript 在带有ui路由器的Angularjs中,如何在不重新加载控制器但保持子视图路由启用的情况下更改哈希值
简而言之:我的,如何拥有子视图?(无需重新加载页面) 更长时间: 我使用提供不同的屏幕效果()。这个指令默认不支持ui路由器,所以我必须自己做 在触发Snap事件之前移动鼠标滚轮时。我调用ui路由器Javascript 在带有ui路由器的Angularjs中,如何在不重新加载控制器但保持子视图路由启用的情况下更改哈希值,javascript,angularjs,hash,angular-ui-router,angularjs-routing,Javascript,Angularjs,Hash,Angular Ui Router,Angularjs Routing,简而言之:我的,如何拥有子视图?(无需重新加载页面) 更长时间: 我使用提供不同的屏幕效果()。这个指令默认不支持ui路由器,所以我必须自己做 在触发Snap事件之前移动鼠标滚轮时。我调用ui路由器$state.go更改URL哈希。我不重新加载控制器 $scope.beforeSnap = function (snapIndex) { $state.go('view' + snapIndex,{},{ notify:false, reload:false,
$state.go
更改URL哈希。我不重新加载控制器
$scope.beforeSnap = function (snapIndex) {
$state.go('view' + snapIndex,{},{
notify:false,
reload:false,
location:'replace',
inherit:true
});
};
路由就像
.state('main', {
url: '/',
templateUrl: 'views/screens.html',
controller: 'mainCtrl'
})
.state('view0', {
url: '/green',
templateUrl: 'views/screens.html',
controller: 'mainCtrl',
params: {'color': 'green', 'screenIndex': 0}
})
[...]
views/screens.html:
<div fit-window-height="" snapscroll="" snap-index="snapIndex" before-snap="beforeSnap(snapIndex)">
<div class="green"></div>
<div class="blue">
<!-- How to enable these subviews? -->
<!-- <a ui-sref="view0.a">Go to view0.a</a> -->
<!-- <a ui-sref="view0.b">Go to view0.b</a> -->
<div ui-view="view1"></div>
</div>
<div class="red"></div>
<div class="yellow">
<div ui-view="view3"></div>
</div>
</div>