0

I'm new to Angular 2.

Can someone please explain the difference between the html directives and attribute directives? Why are they both needed?

Example:

<rating [rate]="rate" (rate-change)="onUpdate($event)"></rating>

So:

rating is what i call "html directive" but I'm not sure what it's for?

[rate] is an attribute directive that sets component property named "rate".

(rate-change) is an attribute directive that calls a component method called rateChange.

Any other types of directives?

1
  • i meant to the difference between html directives and attribute directives Commented Aug 14, 2016 at 13:41

1 Answer 1

1

html directives are for managing dom elements like creating elements. attribute directives modify properties of elements. so angular could create several divs, then later change a div's text.

Sign up to request clarification or add additional context in comments.

1 Comment

in the example above? why is there <rating> what is this translated to?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.