gpt4 book ai didi

javascript - 从孙子导航到父级时,AngularJS UI 路由器数据仍然存在

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:43:23 26 4
gpt4 key购买 nike

从孙子( /dashboard/1/production )导航到父( /dashboard )时,我遇到了奇怪的问题,可能是缓存问题。

以下是几张截图:
enter image description here
enter image description here
enter image description here
enter image description here

选择即 Delphi-UIproduction不应该坚持。

以下是我的片段 application config :

$stateProvider
.state('root', {
url: '/',
views: {
'header': {
templateUrl: 'ngapp/templates/header.html'
}
}
})
// dashboard routes
.state('root.dashboard', {
url: 'dashboard',
views: {
'content@' : {
templateUrl: 'ngapp/home/templates/dashboard.html',
controller: 'DashboardCtrl',
controllerAs: 'vm'
}
}
})
.state('root.dashboard.app', {
url: '/{id:int}',
views: {
'body@root.dashboard' : {
templateUrl: 'ngapp/home/templates/dashboard-body.html',
controller: 'DashboardBodyCtrl'
}
}
})
.state('root.dashboard.app.env', {
url: '/:name',
views: {
'body@root.dashboard' : {
templateUrl: 'ngapp/home/templates/env-content.html',
controller: 'EnvContentCtrl'
}
}
});

DashboardCtrl是:
controllers.controller('DashboardCtrl', ['$scope', '$http', '$state', '$timeout', 'appsFactory', function($scope, $http, $state, $timeout, appsFactory) {

$scope.envs = [];
$scope.deps = [];
$scope.envBtnText = $scope.appBtnText = "Choose here";
$scope.headerTitle = "Environment Configuration And Management";
$scope.appStatus = {
isopen: false
};
$scope.envStatus = {
isopen: false
};

appsFactory.list(function(data) {
$scope.apps = data;
});
}]);

完整的 Controller 代码: http://goo.gl/BWtiU5

项目托管在这里: https://github.com/budhrg/atlantis-dashboard

此外,导航回 Atlantis UI(dashboard)不会像这样重置数据
$scope.envs , $scope.deps , $scope.envBtnText$scope.appBtnText .

这里可能有什么问题?我错过了什么吗?

最佳答案

Nested States & Views

When the application is in a particular state—when a state is "active"—all of its ancestor states are implicitly active as well. Below, when the "contacts.list" state is active, the "contacts" state is implicitly active as well, because it's the parent state to "contacts.list".


您的 Controller 没有被重新实例化(预期)。有几种方法可以处理这个问题。
看:
  • How to make angular ui-router's parent state always execute controller code when state changes?
  • 关于javascript - 从孙子导航到父级时,AngularJS UI 路由器数据仍然存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29366673/

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