Ошибка синтаксического анализа шаблона при использовании datepicker ng2-boostrap с проектом angular2-seed

Я пытаюсь использовать datepicker из ng2-bootstrap в проекте angular2-seed и получаю следующую ошибку. Я использую последнюю версию проекта angular2-seed (angular 2.0.0-rc.3) Заранее благодарим за любые предложения относительно того, что я делаю неправильно.

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>"): AboutComponent@20: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>

My 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 %>'
 }
]);

person chamalabey    schedule 30.06.2016    source источник
comment
Вам не нужно добавлять CORE_DIRECTIVES к поставщикам. Они доступны по всему миру уже довольно давно.   -  person Günter Zöchbauer    schedule 30.06.2016
comment
Я думаю, вы как-то смешиваете старые и новые формы. github.com/valor-software/ng2-bootstrap/issues/638 Не могли бы вы выложить, как выглядит ваш bootstrap(...)?   -  person Günter Zöchbauer    schedule 30.06.2016
comment
Обновили вопрос с помощью кода начальной загрузки   -  person chamalabey    schedule 30.06.2016
comment
@ GünterZöchbauer Я пытаюсь обновить свой проект с angular2 beta до rc3. Вот почему CORE_DIRECTIVES был там. Я удалил его из компонента.   -  person chamalabey    schedule 30.06.2016
comment
Вы не делаете ничего плохого. Если вы посмотрите на проблему, упомянутую @ GünterZöchbauer, вы увидите, что к ней прикреплен запрос на вытягивание.. Когда он будет объединен, это должно решить эту проблему.   -  person Adrian Fâciu    schedule 30.06.2016
comment
Да, вот в чем проблема. На данный момент я закомментировал @ angular / forms. Спасибо.   -  person chamalabey    schedule 30.06.2016


Ответы (1)


PR был объединен, поэтому теперь вы можете использовать

  1. NgModel или FORM_DIRECTIVES из @ angular / forms
  2. и bootstrap (..., [... disableDeprecatedForms (), provideForms (), ...]
person valorkin    schedule 19.07.2016