Bartek Wójcik
Bartek Wójcik

Reputation: 425

NgOneWay and NgAttr - what is the difference?

following AngularDart tutorial: -NgAttr attributes are unidirectional. A copy of the attribute is passed to the component, and each instance of the component has its own copy. The component can change its local value of the property without changing the value outside the component.

and

-NgOneWay attributes are unidirectional. The component's property changes if the expression's value changes, but changing the component's property has no effect outside the component.

so, if i understood correctly both of them are just taking argument and making it local copy that is not shown to the rest of application. What is the difference then? What about the situation when i want to make changes to property only in component and send it to the rest of application without making it possible to change it from there (rest of application). What attribute should i do? Thanks in advance.

Upvotes: 1

Views: 546

Answers (1)

Alex Haslam
Alex Haslam

Reputation: 3499

There is not much difference, but there is a difference.

@NgAttr would be used when you just want to pass a single point of data... say a string.

e.g. max-rating="5"

@NgOneWay would be used when you want to pass an object or compute in the component template.

e.g. value="5+5" or value="Objectvar"

Upvotes: 2

Related Questions