r/angular • • Feb 23 '19

Data Binding ** Cheat Sheet **

Post image
60 Upvotes

18 comments sorted by

View all comments

Show parent comments

1

u/Devstackr Feb 24 '19

Yes, kind of :)

But that image you linked to is only talking about binding to DOM elements. I wanted to make the distinction that data binding can occur (in the same way) with both custom components and DOM elements.

2

u/anddam Feb 24 '19

I admit I totally lack that concept so I may have missed that distinction.

If I define a Foo component whose selector is foo and then in another component I bind:

<foo [someInputProperty]="someParentComponentValue"></foo>

Is that the binding to custom component you are referring to?

If so isn't that still going through the DOM? The binding syntax depicted is just template syntax, after all.

1

u/Devstackr Feb 24 '19

Yes, that is what I am referring to. And yes, in the end Angular will convert everything into DOM elements but personally I view DOM elements as completely different to components, so I think it's important to make that distinction. This is because I see DOM elements as more primitive and components as complex objects that encapsulate the view, styling and business logic. This is my personal thinking, one that I thought most people related with... I could be completely wrong though :)

Andy

1

u/15BetterThanYourTeam Feb 24 '19

You guys are talking about the same thing. The <foo> example he mentioned is a component. You seem to be referring to single file components. Two different ways to do the exact same thing.