nativescript-community / ui-material-components

Monorepo that contains all of the NativeScript Material Design plugins.
https://nativescript-community.github.io/ui-material-components/
Apache License 2.0
218 stars 80 forks source link

MDTabs selectedIndex not woking #446

Open juniorschen opened 1 year ago

juniorschen commented 1 year ago

selectedIndex does not work, if I click on the item that would be selected nothing happens. image

"dependencies": { "@angular/animations": "~14.0.6", "@angular/common": "~14.0.6", "@angular/compiler": "~14.0.6", "@angular/core": "~14.0.6", "@angular/forms": "~14.0.6", "@angular/platform-browser": "~14.0.6", "@angular/platform-browser-dynamic": "~14.0.6", "@angular/router": "~14.0.6", "@bigin/ns-url-handler": "^1.0.6", "@finanzritter/nativescript-share-file": "^2.1.0", "@nativescript-community/sentry": "^3.1.3", "@nativescript-community/ui-material-bottom-navigation": "7.0.20", "@nativescript-community/ui-material-tabs": "7.1.3", "@nativescript-community/ui-pager": "^13.0.35", "@nativescript/angular": "~14.0.2", "@nativescript/core": "~8.3.0", "@nativescript/datetimepicker": "^2.1.10", "@nativescript/geolocation": "^8.0.2", "@nativescript/google-maps": "1.4.4", "@nativescript/theme": "~3.0.2", "@nativescript/unit-test-runner": "^3.0.4", "@ngx-translate/core": "^14.0.0", "@nstudio/nativescript-cardview": "^2.0.1", "@nstudio/nativescript-loading-indicator": "^4.1.2", "@triniwiz/nativescript-toasty": "^4.1.3", "angular2-uuid": "^1.1.1", "decode-google-map-polyline": "^1.0.1", "jwt-decode": "^3.1.2", "nativescript-barcodescanner": "^4.1.2", "nativescript-exit": "^1.0.1", "nativescript-oauth2": "^3.0.9", "nativescript-pdf-view": "^3.0.0-1", "nativescript-sqlite": "^2.8.6", "nativescript-ui-autocomplete": "^15.2.3", "nativescript-ui-calendar": "^8.0.2", "nativescript-ui-chart": "^9.0.1", "nativescript-ui-listview": "^10.0.2", "nativescript-ui-sidedrawer": "^10.0.2", "rxjs": "~7.5.0", "zone.js": "~0.11.5" }, "devDependencies": { "@angular-devkit/build-angular": "~14.0.6", "@angular/compiler-cli": "~14.0.6", "@jsdevtools/coverage-istanbul-loader": "3.0.5", "@nativescript/android": "8.2.4", "@nativescript/ios": "8.5.2", "@nativescript/types": "~8.2.0", "@nativescript/webpack": "~5.0.6", "@ngtools/webpack": "~14.0.6", "@types/jasmine": "4.0.0", "karma": "6.3.0", "karma-coverage": "2.2.0", "karma-jasmine": "4.0.2", "karma-nativescript-launcher": "0.4.0", "nyc": "15.1.0", "typescript": "~4.7.0" }

guillemc23 commented 10 months ago

Hey @juniorschen, It does work for me on Android and 7.2.21. You can use this property as follows:

<MDTabs selectedIndex="0" (selectedIndexChanged)="onSelectedIndexChange($event)">

where

onSelectedIndexChange(args) {
    console.log(args.newIndex)
}

selectedIndex states in which tab the view should render the first time and selectedIndexChanged triggers each time you change the Tab.