hasContent.component.ts 661B

1234567891011121314151617181920
  1. import { Component, OnInit, ViewChild, ElementRef, AfterViewInit, Output, EventEmitter, Input } from '@angular/core';
  2. import { Content } from '@angular/compiler/src/render3/r3_ast';
  3. @Component({
  4. selector: 'app-content',
  5. templateUrl: './hasContent.component.html',
  6. styleUrls: ['./hasContent.component.css']
  7. })
  8. export class HasContentComponent implements AfterViewInit {
  9. @ViewChild('content') content: ElementRef;
  10. @Input() hasChild: Boolean = false;
  11. @Output() hasChildChange : EventEmitter<Boolean> = new EventEmitter<Boolean>()
  12. constructor() { }
  13. ngAfterViewInit(){
  14. this.hasChildChange.emit(!!this.content.nativeElement.childNodes.length);
  15. }
  16. }