使用带有angular2-seed项目的ng2-boostrap datepicker时模板解析错误

时间:2016-06-30 05:36:54

标签: angular datepicker ng2-bootstrap

我正在尝试使用angular2-seed项目中的ng2-bootstrap中的datepicker,我收到以下错误。我正在使用最新版本的angular2-seed项目(角度2.0.0-rc.3) 提前感谢您对我做错的任何建议。

<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.html

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});
  }
}

我的about.component.ts

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

My Bootstrap代码

(function () {
"use strict";
var app = angular.module("autoQuote",["ui.router","ngResource"]);
    .controller('autoQuoteCtrl.js', [function() {
angular.element(document).ready(function () {

});
app.config(["$stateProvider","$urlRouterProvider", function($stateProvider,$urlRouterProvider){
    $urlRouterProvider.otherwise("/");

    $stateProvider
        .state("step1", {
          url : "/",
          templateUrl : "easyquote/step1.html",
          controller: "questionsCtrl",
        })       


        .state("step2", {
          url : "/step2",
          templateUrl : "easyquote/step2.html",
          controller: "questionsCtrl",
        })
}]
);
 }());

1 个答案:

答案 0 :(得分:1)

PR已合并,所以现在您需要使用

  1. 来自@ angular / forms
  2. 的NgModel或FORM_DIRECTIVES
  3. 和bootstrap(...,[... disableDeprecatedForms(),provideForms(),...]