salix/front/core/components/slot/portal.js

29 lines
591 B
JavaScript
Raw Normal View History

2019-11-10 10:08:44 +00:00
import ngModule from '../../module';
/**
* Component used to fill slots with content.
*/
export default class Portal {
constructor($transclude, vnSlotService) {
this.$transclude = $transclude;
this.vnSlotService = vnSlotService;
}
$postLink() {
this.vnSlotService.push(this.slot, this.$transclude);
}
$onDestroy() {
this.vnSlotService.pop(this.slot);
}
}
Portal.$inject = ['$transclude', 'vnSlotService'];
ngModule.component('vnPortal', {
controller: Portal,
transclude: true,
bindings: {
slot: '@'
}
});