如何在Angular 8中创建和指向嵌套组件

问题描述 投票:1回答:2

我有一个具有以下结构的Angular应用程序

|— src
    |— app
        |— user
            |— collection
                |— collection.component.html
                |— collection.component.scss
                |— collection.component.ts
            |— user.component.html
            |— user.component.scss
            |— user.component.ts
    ...

如何直接从用户组件指向收集组件?

angular nested angular8 angular-components
2个回答
1
投票

在用户组件模板的内部使用连接组件的选择器标记。

如果连接组件采用任何@Input参数,则在另一个组件内部使用它时,请确保提供它们。

注意-如果两个组件都在同一模块中声明,则可以使用此功能

您可以参考this video tutorial


1
投票

在user.component.ts中,您可以

import { CollectionComponent } from './collection/collection.component'
© www.soinside.com 2019 - 2024. All rights reserved.