Created
October 21, 2017 07:06
-
-
Save rahulrsingh09/b1f91d4d5271caf0965136a439d0de5f to your computer and use it in GitHub Desktop.
View Child Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Shadow DOM - is an internal DOM of your component that is defined by you (as a creator of the component) | |
// and hidden from an end-user. For example: | |
@Component({ | |
selector: 'some-component', | |
template: ` | |
<h1>I am Shadow DOM!</h1> | |
<h2>Nice to meet you :)</h2> | |
<ng-content></ng-content> | |
`; | |
}) | |
class SomeComponent { /* ... */ } | |
// Light DOM - is a DOM that an end-user of your component supply into your component. For example: | |
@Component({ | |
selector: 'another-component', | |
directives: [SomeComponent], | |
template: ` | |
<some-component> | |
<h1>Hi! I am Light DOM!</h1> | |
<h2>So happy to see you!</h2> | |
</some-component> | |
` | |
}) | |
class AnotherComponent { /* ... */ } | |
// The difference between @ViewChildren and @ContentChildren is that @ViewChildren look for elements in Shadow DOM | |
// while @ContentChildren look for them in Light DOM. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment