【发布时间】:2016-09-06 20:10:17
【问题描述】:
我有一个 div 包含三个其他的,每个都有自己的控制器。我想根据从每个控制器获得的结果动态显示一条消息。例如,如果解析的 3 个数组中有 1 个的长度大于 0,我想在警告消息中反映这一点。我试图在三个子控制器周围放置一个父控制器,但我无法从父控制器访问子控制器的范围,无论如何这似乎不正确。任何帮助将不胜感激。
<div id="pp-summary" ng-controller='PPSummaryCtrl as summCtrl'>
<div id="pp-stats-summary" ng-controller='PlayerProfileStatsCtrl as s'>
<page-section section-title="'Recent Statistics'" excel="{ data: s.statList, definitions: s.summaryHeaders, name: s.player.fullName + ' - Summary Stats' }" >
<core-table
table-sort
parent-child-rows
data="s.statList"
footer-data="s.statTotals"
columns="s.summaryHeaders">
</core-table>
</page-section>
</div>
<div ng-controller="PPScoutingCtrl as e">
<h3 ng-if="!e.permission" id="no-eval-message">
You do not have permissions to view evals on file for this player.
</h3>
<page-section ng-repeat="type in e.evalTypes" section-title="'Recent '+type.description + ' Evals'" ng-if="e.evalsByType[type.evalTypeLk]"
excel="{data: e.evalsByType[type.evalTypeLk], definitions: e.getColumns(type.evalTypeLk), name: e.player.fullName + ' ' + type.description}"
>
<c-table columns="e.getColumns(type.evalTypeLk)" data="e.evalsByType[type.evalTypeLk]" group-rows="true" click-row="e.selectEval" class="table-overflow wrap-last-column"></c-table>
</page-section>
</div>
<div ng-controller="PPNotesCtrl as n">
<page-section ng-if="n.notes" section-title="'Recent Notes'">
<c-table data="n.notes" click-row="n.selectNote" highlight="n.highlight" class="table-overflow" columns="n.noteColumns">
</c-table>
</page-section>
</div>
<h3 id="no-eval-message">
{{ summCtrl.getWarningMessage() }}
</h3>
</div>
【问题讨论】:
-
$scope.$emit在您的子控制器中和$scope.$on在您的父控制器中。
标签: javascript angularjs