angular-ui
tabsを使用して、各タブをクリックするだけで、さまざまなコントローラーからさまざまな関数を呼び出そうとしていますdirective
。
HTML
<tabset>
<tab heading="Reports" ng-controller="ReportsController" ng-click="fetchReports()" id="tab1">
<div> Reports </div>
</tab>
<tab heading="Sales" ng-controller="SalesController" ng-click="fetchSales()" id="tab2">
<div> Sales </div>
</tab>
</tabset>
このようなエラーが発生しています
新しい/分離されたスコープを求める複数のディレクティブ [ngController、tab]
要件
I have 5-6 tabs in a page. The page should not load the data of each tab at once. It should only load data for a tab once that tab is being clicked.
解決
tabset
ディレクティブをラップして、それぞれのコントローラーから関数を呼び出すためのイベントparent controller
を取得できるようにするソリューションがあります。broadcast
ParentController
Child
<div ng-controller='ParentController'>
<tabset>
<tab heading="Reports" id="tab1">
<div ng-controller="ChildOneController"> Reports </div>
</tab>
<tab heading="Sales" id="tab2">
<div ng-controller="ChildTwoController"> Sales </div>
</tab>
</tabset>
</div>
問題:
しかし、悲しいことに、私のアプリケーションにはタブを含むページが多すぎParentController
ますChildController
。私はそれのための良い解決策が何であるかを知る必要がありますか?