在Angular 2中显示模态弹出窗口

时间:2017-04-20 02:00:57

标签: angular modal-dialog popupwindow angular2-directives

我正在尝试根据此帖子中提供的实现将模式集成到我的页面 How to pass data to bootstrap modal dialog in Angular2 这里提供了工作的plunker解决方案http://plnkr.co/edit/8wBnEHOS5zNGXNhg9Tzy?p=preview

我在AngularJs中创建了一个新的plunkr(As Angular2)选项不存在。但是,当将AppComponent / ModalComponent添加到我的app.ts文件时,我看到了一个错误

   description"XHR error (404 Not Found) loading             http://run.plnkr.co/qf9bnaF8YtMFzfz9/app/app.component"

以下是我的plunker代码链接 - http://plnkr.co/edit/pRTaxiaU2S9dtiLYPEtl。有人能帮助我这里出错吗?谢谢!!!

2 个答案:

答案 0 :(得分:1)

根据this question的参考,请按以下步骤操作。

import { CommonModule } from '@angular/common';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
import { CustomComponent } from './custom.component';

@NgModule({
  declarations: [ CustomComponent ],
  exports: [ CustomComponent ],
  imports: [ CommonModule ],
  schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
export class CustomModule {}

您需要做的就是在@NgModule中添加架构。希望你能得到解决方案。

答案 1 :(得分:0)

在app.module.ts

中添加modal.component.ts
import { ModalComponent } from 'location of modal component'

declarations: [
       ModalComponent,
       .......
 ]
相关问题