1

I have component with ng-content in it`s template.

@Component({
  selector: 'some-cmp',
  template: `<ng-content></ng-content>`
})
export class SomeCmp {

}

So I can use it like that:

<some-cmp></some-cmp>

// or

<some-cmp>
  <span>xyz</span>
</some-cmp>

How to correctly check if somebody was passed as content or nothing was passed in the component?

I just need to check if anything is between > and </ of my component selector.

Sharikov Vladislav
  • 7,049
  • 9
  • 50
  • 87
  • 3
    Possible duplicate of [In Angular 2 how to check whether is empty?](https://stackoverflow.com/questions/35107211/in-angular-2-how-to-check-whether-ng-content-is-empty) – You Nguyen Sep 24 '18 at 12:46
  • See: https://stackoverflow.com/questions/50532829/angular-ng-content-how-to-find-element-inside – Frank Fajardo Sep 24 '18 at 12:49

1 Answers1

1

If this is a styling based question, you can look into the :empty CSS selector

scottmgerstl
  • 765
  • 8
  • 18