ialexander
ialexander

Reputation: 910

Passing function into directive versus property value

If I have a custom directive that has an attribute on it:

<my-directive data-value="myController.somePropertyOnAController"><my-d...>

Is there any difference at all between passing that property from the controller to the directive and using a function to pass that property to the directive as long as they both pass the same property value?

<my-directive data-value="myController.getSomePropertyOnAController()"><my-d...>

I was told today that dirty checking can't happen properly in the second case and I have not been able to find anything to that effect. I'm trying to understand why using a function would interfere here.

Upvotes: 0

Views: 46

Answers (1)

Hadi
Hadi

Reputation: 17299

The scope of directive have several type as below.

`@` Attribute string binding

`=` Two-way model binding

`&` Callback method binding

`<` One-way binding

when you pass a function to property of directive that its scope's type is string(i.e @) then that function interpret as string. for more information you can see this link

Upvotes: 1

Related Questions