You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dynamic binding for *tabItem directive to show selected iconSource #332
Hi, I'm trying to make my tabItems dynamic. I'm trying to replace my icon.png the same way that it's done on marketplace app.
I believe the tabItem directive gets wherever is on it's ngOnInit and after that won't update anymore. Are there any way to bind(watch) values, instead? So we could update the sourceIcon or text?
<TabView [(ngModel)]="selectedIndex">
<StackLayout *tabItem="{title: 'Tab1', iconSource: selectedIndex == 1 ? 'res://icona' : 'res://icona1'}">
<Labeltext="You are in Tab 1"></Label>
<Labeltext="{{selectedIndex}}"></Label>
</StackLayout>
<StackLayout *tabItem="{title: 'Tab2', iconSource: selectedIndex == 1 ? 'res://iconb' : 'res://iconb1'}">
<Labeltext="You are in Tab 2"></Label>
<Labeltext="{{selectedIndex}}"></Label>
</StackLayout>
</TabView>
My label shows the correct selectedIndex, but the Tab keeps as it is on load. If I set selectedIndex = 1 on my ngOnInit, shows the second tab selected tab, but after that, won't change the icon. The tab works great.
changed the title [-]Dynamic binding for *tabItem directive to show selected sourceIcon[/-][+]Dynamic binding for *tabItem directive to show selected iconSource[/+]on Jul 8, 2016
Exactly my problem.. I even tried replacing the whole JSON object, like: *tabItem="selectedIndex == 1 ? { title: 'Tab1', iconSource:'res://icona'} : { title: 'Tab1', iconSource:'res://icona1'}"
But it didn't work either.
We are working on a solution for this scenario and it will be available by the end of the day in master branch (so 2-3 days after will be available in npm too). When I push the change will post a sample example how to use the new functionality of the TabViewDirective.
Sorry for the inconvenience caused.
Yep this is online now. For more information how to used it just review ng-sample\app\examples\tab-view\tab-view-test.html first tab. The example shows a binding for title property, but I can ensure you that it also works for iconSource.
Hi @NathanWalker, thanks for that.
However, I believe the next version is getting an error perhaps with the router, because it's happening only while I redirect with router.navigate()
file:///app/tns_modules/@angular/platform-server/src/parse5_adapter.js:619:96: JS ERROR Error: not implemented
I might investigate it later or just wait for the next release be published.
Hi @leocaseiro,
nativescript-angular@0.2.1-2016-07-18-737 build should work fine with TabView iconSource binding. Could you please try it on a separate project (to eliminate any router related problems) and let me know how it goes? It will help me to fix any problem with TabView directive before official release. Thanks in advance.
Hi @nsndeck, first of all, I'm sorry I didn't test before. I didn't have time to.
Well, thank you so much for this fix. I've just updated to the new nativescript-angular@0.3.1 and it's working nice.
I'm able to custom the title and the iconSource as you mentioned.
However, I've noticed that the selectedColor is not working for my iconSource. They still getting the ios blue on selectedColor. It only works for text color.
Could you please help me with that?
It supposed to be a red #d8292f icon instead, but I'm getting grey(unselected) and blue(selected) only on ios. (need to test on android)
Activity
[-]Dynamic binding for *tabItem directive to show selected sourceIcon[/-][+]Dynamic binding for *tabItem directive to show selected iconSource[/+]aalhaimi commentedon Jul 12, 2016
Exactly my problem.. I even tried replacing the whole JSON object, like:
*tabItem="selectedIndex == 1 ? { title: 'Tab1', iconSource:'res://icona'} : { title: 'Tab1', iconSource:'res://icona1'}"But it didn't work either.
aalhaimi commentedon Jul 13, 2016
My temporary solution is to leave the icons fixed, and just change the text font color.. You can check it out here.
nsndeck commentedon Jul 13, 2016
We are working on a solution for this scenario and it will be available by the end of the day in master branch (so 2-3 days after will be available in npm too). When I push the change will post a sample example how to use the new functionality of the TabViewDirective.
Sorry for the inconvenience caused.
leocaseiro commentedon Jul 13, 2016
Thank you both for big help.
aalhaimi commentedon Jul 13, 2016
Awesome.. Just saw the update in the master branch. Thanks @nsndeck!
nsndeck commentedon Jul 13, 2016
Yep this is online now. For more information how to used it just review
ng-sample\app\examples\tab-view\tab-view-test.htmlfirst tab. The example shows a binding fortitleproperty, but I can ensure you that it also works foriconSource.leocaseiro commentedon Jul 19, 2016
Hi @nsndeck, thank you for this fix.
I'd like to test it on my app, how do I use the newest code for
nativescript-angular?Do I need to wait for the npm?
Thanks
leocaseiro commentedon Jul 20, 2016
I've tried to install versions
nativescript-angular@0.2.1andnativescript-angular@0.2.1-2016-07-18-737, however, both are not working properly.I'll wait for the next release.
NathanWalker commentedon Jul 20, 2016
@leocaseiro you can use now with their recent
nextbuild setup. Point your npm package to this:"nativescript-angular": "next"👍
leocaseiro commentedon Jul 20, 2016
Hi @NathanWalker, thanks for that.
However, I believe the
nextversion is getting an error perhaps with the router, because it's happening only while I redirect withrouter.navigate()I might investigate it later or just wait for the next release be published.
Again, Thanks for that.
nsndeck commentedon Jul 20, 2016
Hi @leocaseiro,
nativescript-angular@0.2.1-2016-07-18-737 build should work fine with TabView iconSource binding. Could you please try it on a separate project (to eliminate any router related problems) and let me know how it goes? It will help me to fix any problem with TabView directive before official release. Thanks in advance.
leocaseiro commentedon Aug 12, 2016
Hi @nsndeck, first of all, I'm sorry I didn't test before. I didn't have time to.
Well, thank you so much for this fix. I've just updated to the new
nativescript-angular@0.3.1and it's working nice.I'm able to custom the
titleand theiconSourceas you mentioned.However, I've noticed that the selectedColor is not working for my iconSource. They still getting the ios blue on selectedColor. It only works for text color.
My html:
Could you please help me with that?
It supposed to be a red
#d8292ficon instead, but I'm getting grey(unselected) and blue(selected) only on ios. (need to test on android)Thanks.
Ihor912 commentedon Sep 6, 2018
Hi guys,
This solution for me. Maybe it will help someone else.
I use two different icons for the selection state and for the inactive state.
Also, property iosIconRenderingMode value should be "alwaysOriginal".
In template:
In component: