I'm building a container, which has a header and a content. I can toggle the container by clicking on the header and show my content stuff. In my header there are also some informations, that are visible in every toggle state. It looks like this:
closed (just header stuff):
opened (header and content stuff):
I used angular component to build this:
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:
<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>
Using myContainer in my code:
<my-container header-title="my container">
transcluded things
</my-container>
As you can see, I'm using a binding
to set my container title and transclude my content stuff with ng-transclude
. Now I would like to set my container title also with an ng-transclude
. My problem is, that I don't know how to distinguish the transcluded stuff for my title and my content? I tried to build an own component for the header and put it within the <my-container></my-container>
stuff and also use ng-transclude
but I didn't get the final solution. I hope it's clear enough, any ideas?