Angular自定义模块无法加载

时间:2020-05-09 09:42:08

标签: angular angular-components

对于大多数人来说可能很明显,但我自己仍然找不到。

我有一个角度申请和以下相关文件

app/app.module.ts
app/dashboard/dashboard.component.html
app/dashboard/stats-tile/stats-tile.component.html

我用ng generate生成了stats-tile组件,因此在导入的app.module.ts中以及声明中:

//app.module.ts
declarations: [
AppComponent,
TournamentSearchComponent,
DashboardComponent,
StatsTileComponent
],

现在我想显示stats-tile组件

//dashboard.component.html
<app-dashboard-stats-tile></app-dashboard-stats-tile>

我得到:

Error: Template parse errors:
'app-dashboard-stats-tile' is not a known element:

我在做什么错。我可以使用我在应用程序组件中生成的另一个组件。我在子文件夹中生成它时有什么区别吗? 我对angular有点陌生,但我的理解是app.module.ts中导入/声明的所有内容都可用于整个应用程序。

1 个答案:

答案 0 :(得分:1)

根据文件名,我的猜测是您在此处使用了错误的名称:

            var obj = (from c in doc.Elements("item")
                select new
                {
                    TicketID = c.Element("key")?.Value,
                    Summary = c.Element("summary")?.Value,
                    ReporterNT = c.Element("reporter")?.Attribute("username")?.Value,
                    ReporterFull = c.Element("reporter").Value,
                    FirstName = (from f in c.Descendants("customfields")
                        where f.Element("customfield")?.Attribute("id")?.Value == "customfield_37723"
                        select f.Descendants("customfieldvalues").FirstOrDefault()?.Value).FirstOrDefault()
                }).ToList();

此组件<app-dashboard-stats-tile></app-dashboard-stats-tile> 文件的名称为“ dashboard-stats-tile.ts”。

您可能希望将此行替换为:

.ts