'tables-basic'是一个Angular组件,然后验证它是否是此模块的一部分 [英] 'tables-basic' is an Angular component, then verify that it is part of this module

查看:42
本文介绍了'tables-basic'是一个Angular组件,然后验证它是否是此模块的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个table-basic.component.ts,其中我声明了"tables-basic"作为选择器,并在dashboard.html中调用了模板,我按照以下过程进行操作,但仍然出现错误,这我也在下面提到了.

I have a table-basic.component.ts in which i declared 'tables-basic' as a selector and i am calling the template in dashboard.html and i followed the below process but still i did got an error,which i also mentioned below.

我的dashboard.template.html,

My dashboard.template.html,

  <div href='#tab2'>
      <div id='tab2'>
       <tables-basic></tables-basic>
       </div>
     </div>

我的ts

import { Component, ViewEncapsulation } from '@angular/core';
import { TablesBasic } from '../tables/basic/tables-basic.component';
import { AppConfig } from '../app.config';

@Component({
  selector: 'dashboard',
  templateUrl: './dashboard.template.html'

})
export class Dashboard {
  config: any;
  month: any;
  year: any;
}

错误

   main.browser.ts:25Error: Template parse errors:(…)(anonymous function) @ main.browser.ts:25ZoneDelegate.invoke 
      @ zone.js:203Zone.run 
      @ zone.js:96(anonymous function) 
      @ zone.js:462ZoneDelegate.invokeTask 
      @ zone.js:236Zone.runTask 
      @ zone.js:136drainMicroTaskQueue 
      @ zone.js:368ZoneTask.invoke 
      @ zone.js:308

我不知道此错误,请问有人可以帮忙吗.

I dont know about this error,can any one suggest help please.

推荐答案

您需要将 TableBasicComponent 添加到 parent 组件模块的声明中.

You need to add TableBasicComponent to declarations of parent components module.

import { TableBasicComponent } from 'path/to/component'

@NgModule({
  declarations: [
    TableBasicComponent // < --- added here
  ],
  imports: [
  ],
  providers: []
})
export class DashboardModule { }

这篇关于'tables-basic'是一个Angular组件,然后验证它是否是此模块的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆