私はヘッダとコンテンツを持つコンテナを構築しています。ヘッダーをクリックしてコンテナーを切り替えることができ、コンテンツの内容を表示できます。私の見出しには、すべてのトグル状態で表示される情報もあります。それは次のようになります。同じコンポーネントにng-transcludeを複数回使用する
クローズは(単にものをヘッダー):
開く(ヘッダと内容のもの):私はこれを構築するために角度成分を使用
:
myContainer.ts:
/** @ngInject */
export class MyContainer extends Controller {
static componentName = 'myContainer';
static templateUrl = 'app/comp/components/myContainer/myContainer.html';
static componentOptions: ng.IComponentOptions = {
transclude: true,
bindings: {
headerTitle: '@'
}
};
headerTitle: string;
isShownBlock: boolean = false;
constructor(
) {
super();
}
}
myContainer.html:私のコードでmyContainerを使用して
<div class="containerHeader" ng-click="ctrl.isShownBlock = !ctrl.isShownBlock">
<my-icon icon="arrow-filled"></my-icon>
<div class="containerTitle">{{ctrl.headerTitle}}</div>
</div>
<div class="containerContent" ng-if="ctrl.isShownBlock">
<div class="containerInnerContent" ng-transclude>
<!--TRANSCLUDED_CONTENT-->
</div>
</div>
:
<my-container header-title="my container">
transcluded things
</my-container>
あなたが見ることができるように、私は私のコンテナのタイトルを設定するbinding
を使用していますし、私のコンテンツをng-transclude
で埋め尽くしてください。今私はng-transclude
でコンテナのタイトルを設定したいと思います。私の問題は、私のタイトルと私のコンテンツのために継承されたものを区別する方法がわからないということですか?私はヘッダーのための独自のコンポーネントを構築し、<my-container></my-container>
のものに入れて、またng-transclude
を使用しようとしましたが、私は最終的な解決策を得ていませんでした。私はそれが十分に、任意のアイデアを望む?