2017-08-28 74 views
0

我正在使用Angular 4和Angular Material 2.我希望为创建每个菜单选项的组件提供一些建议。我的菜单有4个类别,每个类别有5个子类别。内容是应用程序。我必须根据类别和子类别显示应用程序。 类别的内容应该看起来像这个模型。它具有部分(新的软件,最后添加,子类别1,子类别2等...)为菜单选项创建组件的建议

类别的内容

子类别有这样的后续实体模型的内容。应用程序只是一个列表

子目录内容

回答

0

我也创建一个购物车应用程序。以下是我的电子类别的快照。我不知道这是否是您正在寻找的方法,但这是我设计电子类别的方式。当然,我的应用程序有很多类别,电子产品 - 电子产品(电脑,手机,智能手表),玩具(娃娃,公主)等。在顶部,我有显示所有类别的旋转木马,下面显示所有类别,其次是电子品牌和电子产品。当我搜索电子产品,我得到它的“PARAMS [ID],并将其传递给作为输入,

"carousel - shows different categories" 
<category [input]="search"></category>, 
<brands [input]="search"></brands> ,and 
<products [input]="search></products>. 

种类和品牌都有自己的班,所以我知道如何寻找他们或显示它们。

export class Category { 
    constructor(
    public name: string, 
    public imageUrl: string, 
    public title?: string, 
    public isFeatured?: boolean, 
    public categoryId?: string) {} 
} 

enter image description here

为了您的信息,YES。我通过我的应用程序使用可重用组件。

+0

嗨,谢谢你的回答。我正在创建一个残疾应用程序商店。它与可重用组件一起工作吗?我想知道是否可以使用ngif来根据类别和子类别显示应用程序。例如:

Steph

+0

@Steph是啊我相信你可以使用'ngIf'来确定应该渲染什么。无论哪种方式创建一个新的项目,并测试以上出去,并从那里去。 –

+0

我使用mongo Db,所以当我想搜索谷歌手机(有品牌和类别)。 router.post('/ brand-category',function(req,res,next){ \t var brand = req.body.brand; \t var category = req.body.category; \t Product.find({品牌':品牌,'category':category})。这样,在我的前端,我得到所有手机产品,但只有google。 –

0

我仍然在学习角度,但对于我的应用程序是现实的,我的应用程序有一个树结构。每个品牌和类别都有自己的路由,这意味着他们拥有自己的标题,家庭和家庭详情。对于我的苹果网站,下面的鞋子路由模块:

// Define the routes 
const routes: Routes = [ 
    { path: 'apple', component: AppleComponent, 
    children: [ 
     { path: 'h/apple', component: AppleAccessoryComponent }, 
     { path: 'iwatch', component: IwatchComponent }, 
     { path: 'about iphone', component: IphoneAboutComponent}, 
     { path: 'iphone', component: IphoneComponent }, 
     { path: 'apple about', component: AppleAboutComponent }, 
     { path: ':id', component: AppleDetailComponent }, 
     { path: '', component: AppleHomeComponent } 
    ] 
    } 
]; 

下面是我的苹果组件的快照。你不介意投我的答案?

enter image description here