Jason K.
Jason K.

Reputation: 838

NativeScript Angular2 Passing context parameter for data binding a function

I have been looking through the documentation and examples but cannot seem to find an appropriate example to pass the source entity to a function for binding.

For example, in trying to bind the "hidden" visibility parameter value to the result of function isHidden(), I would like to pass some sort of variable like callerContext that knows which TextField is is associated with the binding. Does such a variable exist or do I have create a scheme myself?

<TextField class="input" hint="Email address" [hidden]="isHidden(callerContext)"
keyboardType="email" autocorrect="false" autocapitalizationType="none"
[(ngModel)]="contactSettings.emailAddressList[0]" returnKeyType="next" (returnPress)="focusNext()">
</TextField>

Please let me know if this is not clear.

Upvotes: 1

Views: 96

Answers (1)

Manoj
Manoj

Reputation: 21908

There won't be a variable named callerContext until you define one. If you want the textfield reference in isHidden method, then pass the textfield itself

<TextField #txt class="input" hint="Email address" [hidden]="isHidden(txt)" ....

Upvotes: 1

Related Questions