Databinding from within a template in angular


#1

In a component how to databind(two-way) for the following example. (@jen.looper)

Here is the template

<ListView [items]="channels$ | async" class="list-group">
    <ng-template let-dataitem="item">
       <Button [text]="dataitem.isSelected?'UnFollow':'follow'" (tap)="dataitem.isSelected?unfollow(dataitem):follow(dataitem)"></Button>
    </ng-template>
 </ListView>

Here are the functions

 unfollow(dataitem) {
    dataitem.isSelected = true;//not working
 }
 follow(dataitem) {
    dataitem.isSelected = true;//not working
 }

#2

when you tap, is the dataitem.isSelected boolean toggling? There’s an example of this kind of toggling here: https://github.com/NativeScript/workshop/blob/master/demo/app/pet-favorites/pet-favorites.component.html


#4

A proper answer? She just gave you a hint on where to search for information regarding your problem.
You need to overcome the problems yourself.
If everytime you have a problem you ask for the solution you will never evolve and progress.

You should always look for suggestions or hints on how to do something and then do it yourself, this way you improve and become better at it.

And regarding the two-way data binding it is pretty well explained on the Groceries tutorial.


#5

Such answers on stackoverflow generally get downvoted and deleted.
I can provide you hundreds of such links of sample codes but those links are not my problems. My problem is with understanding the flow of the above code.
If my intention was to seek advice on how to search why would I paste the code in the first place?


#6

We are trying to help here. I gave you some pointers. Answering back this way doesn’t make me particularly eager to continue to help.


#7

@ishandutta2007 with a tutorial on how to make friends and influence people…


#8

No issues I may have over reacted, I realised telerik support team might be confined to support related to nativescript documentations which makes sense also.
For code debuging and code analysis questions I will continue on stackoverflow which I am more used to.