Dynamic Ionic2动态导航
我正在构建一个应用程序,其中数据来自服务器。菜单是动态的,服务器可以根据用户配置文件发送不同的菜单。我永远不知道菜单项将包含什么组件/页面,我只需要让该组件/页面可用 主要的问题是我需要导入很多组件/页面,我不想在每个组件/页面中都导入这些内容 我创建了一个服务,在其中进行所有导入,并存在一个方法来返回正确的组件,因此navController可以导航Dynamic Ionic2动态导航,dynamic,angular,menu,navigation,ionic2,Dynamic,Angular,Menu,Navigation,Ionic2,我正在构建一个应用程序,其中数据来自服务器。菜单是动态的,服务器可以根据用户配置文件发送不同的菜单。我永远不知道菜单项将包含什么组件/页面,我只需要让该组件/页面可用 主要的问题是我需要导入很多组件/页面,我不想在每个组件/页面中都导入这些内容 我创建了一个服务,在其中进行所有导入,并存在一个方法来返回正确的组件,因此navController可以导航 import { Injectable } from '@angular/core'; //Import navigation pages i
import { Injectable } from '@angular/core';
//Import navigation pages
import { NotificationsPage } from "./../pages/notifications/notifications";
import { ClubPage } from "./../pages/club/club";
import { ActivitiesPage } from "./../pages/activities/activities";
import { NewsPage } from "./../pages/news/news";
import { CalendarPage } from "./../pages/calendar/calendar";
import { NewsletterPage } from "./../pages/newsletter/newsletter";
import { SettingsPage } from "./../pages/settings/settings";
import { FavoritesPage } from "./../pages/favorites/favorites";
import { SubmenuPage } from "./../pages/submenu/submenu";
import { ContentDetailsPage } from "./../pages/contentdetails/contentdetails";
@Injectable()
export class ViewNavigatorService
{
public NOTIFICATIONS:string = "notifications";
public CLUB:string = "club";
public ACTIVITIES:string = "activities";
public NEWS:string = "news";
public CALENDAR:string = "calendar";
public NEWSLETTER:string = "newsletter";
public SETTINGS:string = "settings";
public FAVORITS:string = "favorits";
public SUBMENU:string = "submenu";
public CONTENT_DETAILS:string = "content-details";
public GetComponent(page:string, data?:any):any
{
let Component = null;
switch (page)
{
case this.NOTIFICATIONS: Component = NotificationsPage; break;
case this.CLUB: Component = ClubPage; break;
case this.ACTIVITIES: Component = ActivitiesPage; break;
case this.NEWS: Component = NewsPage; break;
case this.CALENDAR: Component = CalendarPage; break;
case this.NEWSLETTER: Component = NewsletterPage; break;
case this.SETTINGS: Component = SettingsPage; break;
case this.FAVORITS: Component = FavoritesPage; break;
case this.SUBMENU: Component = SubmenuPage; break;
case this.CONTENT_DETAILS: Component = ContentDetailsPage; break;
default: Component = null; break;
}
return Component;
}
}
如果我只在父页面中注入服务,它可以工作,但是如果我也在子页面中注入服务,我会得到以下错误:
无法解析子菜单页的所有参数:(NavController、NavParams、PopoverController、AlertController、ModalController,?)
那个?应该是“ViewNavigatorService”
为什么会发生这种错误
有更好的方法吗?当应用程序使用动态导航时,您使用的是什么