【发布时间】:2015-08-30 18:35:25
【问题描述】:
我有一个任务,我必须在 3 个选项卡下标记 3 个不同的 html 页面。一旦用户导航到这些页面,所有这些页面都会在网格中加载数据。我可以标记我的 html 页面。有一个有效的 plunkr。 http://plnkr.co/edit/0XgquovKIICmgGcSVSef?p=preview 但问题是现在我无法像之前那样加载带有数据的页面。我哪里可能出错了?这些选项卡式页面不会在网格中加载数据。 html
<style>
ul {
list-style: none;
padding: 0;
margin: 0;
}
li {
float: left;
border: 1px solid #000;
border-bottom-width: 0;
margin: 3px 3px 0px 3px;
padding: 5px 5px 0px 5px;
background-color: none;
color: none;
}
</style>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div id="tabs">
<ul>
<li ng-repeat="tab in tabs"
ng-class="{active:isActiveTab(tab.url)}"
ng-click="onClickTab(tab)">{{tab.title}}</li>
</ul>
<div id="mainView">
<div ng-include="currentTab"></div>
</div>
</div>
</body>
</html>
控制器代码:
b360MyUtilities.controller("TabsController",
[
"$scope",
function ($scope) {
$scope.tabs = [{
title: 'PlanSetupStatus',
controller: "PlanSetupStatusController",
templateUrl: "app/templates/views/utilities/PlanSetupStatus.html"
}, {
title: 'MigrationScheduled',
controller: "MigrationScheduledController",
templateUrl: "app/templates/views/utilities/MigrationHistory.html"
}, {
title: 'MigrationHistory',
controller: "MigrationHistoryController",
templateUrl: "app/templates/views/utilities/MigrationScheduled.html"
}];
$scope.currentTab = "app/templates/views/utilities/PlanSetupStatus.html"
$scope.onClickTab = function (tab) {
$scope.currentTab = tab.templateUrl;
}
$scope.isActiveTab = function (tabUrl) {
return tabUrl == $scope.currentTab;
}
}]);
【问题讨论】:
-
ng-include 不刷新控制器只是一个模板......在这里你正在尝试加载一个控制器,我会使用 ui-router 和 ui-sref 这将让你加载控制器和模板...
标签: javascript jquery angularjs model-view-controller