Dynamic binding for *tabItem directive to show selected iconSource
See original GitHub issueHi, 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'}">
<Label text="You are in Tab 1"></Label>
<Label text="{{selectedIndex}}"></Label>
</StackLayout>
<StackLayout *tabItem="{title: 'Tab2', iconSource: selectedIndex == 1 ? 'res://iconb' : 'res://iconb1'}">
<Label text="You are in Tab 2"></Label>
<Label text="{{selectedIndex}}"></Label>
</StackLayout>
</TabView>
export class AppComponent {
public selectedIndex: number = 0;
}
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.
Thanks
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (9 by maintainers)
Top Results From Across the Web
TabItem binding content dynamically - Stack Overflow
Trying to build a TabControl dynamically, but it won't bind the UserControl I've created. ... {Binding Content} does show a warning,
Read more >TabView - NativeScript Docs
The TabView component provides a simple way to navigate between different views by tapping on some of the tabs or by swiping between...
Read more >AdvancedTabControl - Docking & MDI Reference
Note that in MVVM scenarios, this will return the item that is selected and not the ... Normal tabs appear normally and left-aligned...
Read more >- Welcome to Pega Platform
Adding WAI-ARIA roles to a Dynamic Layout; Adding a main content link to ... the Rule instruction to support a custom rule type;...
Read more >Dynamically creating TabItems with one of the ... - MSDN
That TabItem with IsSelected = true will show the content but the tab itself stays in the background as if it's not selected....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 fortitle
property, but I can ensure you that it also works foriconSource
.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: