【发布时间】:2018-05-24 14:30:00
【问题描述】:
我在 angular 4.4 中遇到问题,在我的应用程序中,我有分层视图。我在其中创建了一个
:= 模块 1 -> 模块 2 -> 我的组件。
我已经正确地声明了一切。 , 但我仍然遇到错误。
- 声明的组件。
- 已将其导入到其他模块中。
- 选择器名称相同。
- 在模块 2 中导出组件。
- 在模块 1 中导入模块 2。
有什么问题? 组件代码: 管理 -> 配置 -> 我的组件 //我的组件
import { Component, OnInit, ViewChild, ChangeDetectorRef } from '@angular/core';
@Component({
selector: 'test-mycomponent',
templateUrl: './mycomponent.component.html',
styleUrls: ['./mycomponent.component.scss']
})
export class MyComponentComponent implements OnInit {
@ViewChild('myComponentTable')
constructor() {
}
ngOnInit() {
//init functionality
}
}
// configure module code
import { NgModule,Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { MyComponentComponent } from './mycomponent/mycomponent.component';
@NgModule({
imports: [
CommonModule,
WidgetsModule,
FormsModule,
NgbModule
],
declarations: [
MyComponent
],
providers: [
],
exports: [
MyComponent
]
})
export class ConfigurationModule { }
//Main module admin
import { NgModule, Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ConfigurationModule } from './configuration/configuration.module';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { MyComponentComponent } from './configuration/mycomponent/mycomponent.component';
import { FormsModule } from '@angular/forms';
@NgModule({
imports: [
CommonModule,
NgbModule,
FormsModule,
ConfigurationModule
],
declarations: [
],
exports: [
]
})
export class AdminModule { }
and I am calling that template in another file
//Test file html
<ng-template>
<test-mycomponent></test-mycomponent>
</ng-template>
【问题讨论】:
-
你能添加代码吗..
-
@AmolRaje 请检查
标签: javascript angular angular2-template