Comments (11)
For optimization purposes the plugin only checks for the available tabs on initialization. I will try to support this in the future but it's not a priority.
For now, what you can do is prevent the component from initializing until you have your tabs ready. Here's a quick example:
<super-tabs *ngIf="tabsLoaded" ...>
<super-tab *ngFor="let tab of tabs" ...></super-tab
</super-tabs>
ionViewDidLoad() {
this.lookservice.getAllcategory().subscribe(countries => {
this.obj_CategorysListData = countries;
this.tabsLoaded = true;
});
}
This will only render your super-tabs
component when the data is ready.
from ionic-super-tabs.
@Topiya , as @ihadeed said, you should not initiate the tabs before getting the data. First, use *ngIf="tabsLoaded"
to indicate the data status. Then bind a variable to the tab as a param like this:
<super-tabs scrollTabs="true" *ngIf="tabsLoaded">
<super-tab *ngFor="let item of countries" [root]="countryPage" [rootParams]="item.country_id" [title]="item.Name"></super-tab>
</super-tabs>
Now you can get the param in the constructor method of the countryPage. Notice that the param must be a string. I don't think it can recieve an object as a param.
from ionic-super-tabs.
@ihadeed
Tried with the above code and implemented in HTML
<super-tabs scrollTabs="true" *ngIf="tabsLoaded">
<super-tab *ngFor="let tab of tabs" [root]="tab.countryName" [title]="tab.countryName"></super-tab>
</super-tabs>
But getting a below error
Runtime Error
Uncaught (in promise): invalid link: Tabname
Can you guide me to solve this?
from ionic-super-tabs.
Show me the code that contains "Tabname" in it. Can't tell what the issue is from the code you provided.
I see that you're setting the root and the title both to tab.countryName
. Is that string a valid page that the lazy loader is able to fetch?
from ionic-super-tabs.
@ihadeed
Thank you for your reply.
[root]="tab.countryName" where countryName column name gives a list of countries(Canada,Australia) for example "Australia", so I have declared a variable Australia = AustraliaPage which is pointing to a AustraliaPage
Code:
ts
import { AustraliaPage } from './australia';
import {CanadaPage} from './canada';
export class CountryPage {
Australia = AustraliaPage;
Canada= CanadaPage;
tabsLoaded = false;
ionViewDidLoad() {
this.testservice.getCoutrynames().subscribe(countries => {
this.tabs = countries;
// below is the output data of getCoutrynames() method
// "countries": [
// {
// "country_id": 1,
// "countryName": "Canada"
// },
// {
// "country_id": 2,
// "countryName": "Australia"
// }
// ]
this.tabsLoaded = true;
})
}
}
HTML
<super-tabs scrollTabs="true" *ngIf="tabsLoaded">
<super-tab *ngFor="let tab of tabs" [root]="tab.countryName" title="tab.countryName"></super-tab>
</super-tabs>
Error
Runtime Error
Uncaught (in promise): invalid link: Australia
from ionic-super-tabs.
@ihadeed
Is there any solution regards to the above comment?
from ionic-super-tabs.
@Topiya the way you have it doesn't work.
You need to add a map variable as follows:
let pages: any = {
Australia: AustraliaPage,
Canada: CanadaPage
};
Then instead of passing tab.countryName
to the root
input, you pass pages[tab.countryName]
.
from ionic-super-tabs.
@ihadeed
Thanks a lot for your solution. It worked for me!!
from ionic-super-tabs.
Perfect! Thanks, @ihadeed
from ionic-super-tabs.
In concern with my above question, I am using countryPage as rootpage for all tabs as mentioned below and fetching data dynamically in countryPage as per the country. This thing I am able to do when declaring pages array as static.
pages: any={
Australia = countryPage;,
Canada= countryPage
}
But when I am trying to fill pages array dynamically as mentioned below, I am getting an error.
this.testservice.getCoutrynames().subscribe(countries => {
this.tabs = countries;
for (let i = 0; i < this.tabs.length; i++) {
this.tabname = this.tabs[i].countryName;
this.pages = {
[this.tabname] : countryPage
}
Error:
Runtime Error
Uncaught (in promise): invalid views to insert
Can anyone help me get the data dynamically?
from ionic-super-tabs.
@yanxiaodi Thanks for the solution.
from ionic-super-tabs.
Related Issues (20)
- tab indicator is not located correctly in firefox when padding exists
- ReIndexTabs undefined issue renders the tab blank HOT 2
- Super Tabs Toolbar pushed up when keyboard is activated HOT 1
- Need help on Super tab containing Table with horizontal scrollbar and fixed column HOT 2
- How to place super-tabs inside ion-toolbar HOT 2
- Framework Delegate is Missing Zone <root> (ion-nav root component not showing in browser) HOT 2
- When i prefetched new tabs list and concat it to the current tabs list the tab toolbar scrolls back to the last selected tab.
- How to change color from indicator and icon on the app?
- in 7.0.8 Version - Its throwing error as Can not read Property 'TransitionDuration' of Undefined. HOT 1
- Angular 10 || 11 and Ionic 5: Generic type 'ModuleWithProviders<T>' requires 1 type argument(s) error HOT 1
- Change tab programmatically. activeTabIndex not work.
- There isn't any props to disable ion-ripple-effect HOT 6
- Lazy loadingn not working - unloadWhenInvisible doing nothing HOT 2
- Tab content become empty when change tabs. Happens only on iOS 14.5 upwards
- super-tab-button animation slides from top on load
- Super Tabs - how to pass page to [root] correctly? HOT 1
- Having two supertabs pages, how to go from first page to second page programmatically?
- ion-refresher doesn't work in multiple tabs
- *ngIf and *ngOf directives not working
- not working on latest ionic v7.1.1 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ionic-super-tabs.