Skip to content

Dynamic binding for *tabItem directive to show selected iconSource #332

@leocaseiro

Description

@leocaseiro

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'}">
        <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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions