1
angular2-seedプロジェクトのng2-bootstrapからdatepickerを使用しようとしていますが、次のエラーが発生します。私は最新のバージョンのangular2-seedプロジェクト(角度2.0.0-rc.3)を使用しています 私が間違っていることについての提案を前もってありがとう。angg2-seedプロジェクトでng2-boostrap datepickerを使用したときのテンプレート解析エラー
platform-browser.umd.js:2311 EXCEPTION: Error: Uncaught (in promise): Template parse errors:No provider for NgModel ("eight:290px;">
<!--<datepicker [(ngModel)]="date" showWeeks="true"></datepicker>-->
[ERROR ->]<datepicker [(ngModel)]="date" [showWeeks]="true"></datepicker>
</div>"): [email protected]:8
マイabout.component.html
<wrapper>
<alert type="info">ng2-bootstrap hello world!</alert>
<div style="display:inline-block; min-height:290px;">
<datepicker [(ngModel)]="date" [showWeeks]="true"></datepicker>
</div>
<alert *ngFor="let alert of alerts;let i = index" [type]="alert.type" dismissible="true" (close)="closeAlert(i)">
{{ alert?.msg }}
</alert>
<alert dismissOnTimeout="5000">This alert will dismiss in 5s</alert>
<button type="button" class='btn btn-primary' (click)="addAlert()">Add Alert</button>
マイabout.component.ts
import {Component} from '@angular/core';
import {AlertComponent, DatePickerComponent} from 'ng2-bootstrap/ng2-bootstrap';
@Component({
selector: 'wrapper',
moduleId: module.id,
templateUrl: './about.component.html',
styleUrls: ['./about.component.css'],
directives: [
AlertComponent,
DatePickerComponent,
CORE_DIRECTIVES
]
})
export class AboutComponent {
date:Date = new Date();
alerts:Array<Object> = [
{
type: 'danger',
msg: 'Oh snap! Change a few things up and try submitting again.'
},
{
type: 'success',
msg: 'Well done! You successfully read this important alert message.',
closable: true
}
];
closeAlert(i:number) {
this.alerts.splice(i, 1);
}
addAlert() {
this.alerts.push({msg: 'Another alert!', type: 'warning', closable: true});
}
}
私のブートストラップコード
import { APP_BASE_HREF } from '@angular/common';
import { disableDeprecatedForms, provideForms } from '@angular/forms/index';
import { enableProdMode } from '@angular/core';
import { bootstrap } from '@angular/platform-browser-dynamic';
import { APP_ROUTER_PROVIDERS } from './app.routes';
import { AppComponent } from './app.component';
if ('<%= ENV %>' === 'prod') { enableProdMode(); }
bootstrap(AppComponent, [
disableDeprecatedForms(),
provideForms(),
APP_ROUTER_PROVIDERS,
{
provide: APP_BASE_HREF,
useValue: '<%= APP_BASE %>'
}
]);
プロバイダーに 'CORE_DIRECTIVES'を追加する必要はありません。彼らはかなりの時間以来、世界的に提供されています。 –
あなたは何とか古いものと新しいものを混ぜていると思います。 https://github.com/valor-software/ng2-bootstrap/issues/638 'bootstrap(...)'の様子を投稿できますか? –
ブートストラップコード – chamalabey