2017-04-01 11 views
0

나는 angular2 및 ng2-bootstrap을 사용하고 있습니다.ng2-bootstrap이 angular2에 alert, datepicker를 등록 할 수 없습니다.

테스트 경고

내 systemjs.config.js : 내 module.ts에서

, 나는이 같은 선언 한 내 구성 요소 템플릿에서이

import { Ng2BootstrapModule, AlertModule } from 'ng2-bootstrap'; 
imports:  [ BrowserModule, 
    ..., 
    Ng2BootstrapModule.forRoot(), 
    AlertModule.forRoot(), 
    ... ] 

같은 선언 한

map:{ 
    ..., 
    'moment': 'npm:moment', 
    'ng2-bootstrap': 'npm:ng2-bootstrap', 
    ... 
}, 
packages: { 
    ..., 
    'moment': { main: 'moment.js', defaultExtension: 'js' }, 
    'ng2-bootstrap': { format: 'cjs', main: 'bundles/ng2-bootstrap.umd.js', defaultExtension: 'js' }, 
    ... 
} 

하지만이 오류가 발생했습니다.

Unhandled Promise rejection: Template parse errors: 
'alert' is not a known element: 
1. If 'alert' is an Angular component, then verify that it is part of this module. 
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. 

무엇이 누락 되었습니까? 그것에 대해 도와주세요. 나는 해결책을 찾기 위해 몇 시간을 보냈지 만 할 수 없었다.

미리 감사드립니다.

+0

선언 NG2 - 부트 스트랩에서 온 Ng2BootstrapModule 필요 in module.ts –

답변

0

당신이 날짜 선택기 및 경보가 필요한 경우, 가져 오기하십시오

import { DatepickerModule, AlertModule } from 'ng2-bootstrap'; 
imports:  [ BrowserModule, 
    ..., 
    DatepickerModule.forRoot(), 
    AlertModule.forRoot(), 

일어날 수있는 무엇 : 각도는 해당 서브 모듈에 렌더링에 사용되는 모듈의 가져 오기가

+0

마지막으로 나는 스스로를 해결합니다. 나는'AppModule.ts'을 메인으로,'QuestionTagModule.ts'는 서브 모듈입니다. 하위 모듈 파일에 import AlertModule이 없습니다. 나는 메인 모듈에서'Ng2BootstrapModule.forRoot()'만을 가져온다. 그건 내 바보 같은 짓이야. 어쨌든 고맙습니다. –

+0

나는 해당 서브 모듈에서 이것을 다시 말해야한다. – valorkin

+0

나는 너를 이해할 수 없으며 나는 같은 문제가있다. 그래서 나는 appmodule에서'AlertModule.forRoot()'을 가져와야하고, 사용하고자하는 컴포넌트의 모듈에서'AlertModule.forRoot()'와 같은 문자열을 가져야한다. 왜 두 번? forRoot()의 경우 부모 appmodule에서 가져 오기만하면됩니다. 맞습니까? –