3
webpack을 사용하고 npm을 사용하여 ng2-select를 설치했고 ng2-bootstrap을 설치하고 올바르게 작동 시켰습니다. 내가 NG2-선택 가져올 때하지만 난 내 콘솔에서 다음과 같은 오류가angular2-rc.7 webpack에서 ng2-select 가져 오기
Uncaught Error: Unexpected directive 'SelectComponent' imported by the module 'AppModule'
이 내 app.module.ts 파일입니다
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { Ng2BootstrapModule } from 'ng2-bootstrap/ng2-bootstrap';
import { SELECT_DIRECTIVES } from "ng2-select/ng2-select";
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule, Ng2BootstrapModule, SELECT_DIRECTIVES],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
app.component.ts
@Component({
selector: 'search',
styleUrls: ['app/assets/ng2-select.css'],
templateUrl: '<ng-select [items]="items" placeholder="Country">
</ng-select>'
})
export class AppComponent {
public items: Array<string> = ['Austria', 'Belgium', 'Bulgaria', 'Croatia',
'Czech Republic', 'Denmark', 'England', 'Egypt', 'Finland', 'France',
'Germany', 'Greece', 'Hungary', 'Ireland', 'Italy', 'Netherlands',
'Poland', 'Spain'];
}
모든 아이디어가이 문제를 해결하는 방법.
ang2를 선택하는 ng2-select (http://valor-software.com/ng2-select/)를 사용하고 있습니다. –
문제는이 lib가 angular2 rc1을 사용하고 있다는 것입니다. 선언문에'SELECT_DIRECTIVES'을 넣으면 문제가 해결 될 수 있습니다. 그렇지 않으면 모듈을 기다려야합니다. – Supamiu
RC7에서'SelectModule'을 사용했습니다. 감사! – BCoder