1
我在啓動我的應用程序時遇到了此錯誤。我在做什麼錯了? 我已經在我的模塊中導入了FormsModule和ReactiveFormsModule包。 我採用了棱角分明2.4.9AngularJS 2:由於它不是「輸入」的已知屬性,因此無法綁定到'ngModel'
app.module.ts:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { HttpModule } from '@angular/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { PainelComponent } from './painel/painel.component';
import { PainelModule } from './painel/painel.module';
import { SidebarModule } from './sidebar/sidebar.module';
import { FooterModule } from './shared/footer/footer.module';
import { NavbarModule} from './shared/navbar/navbar.module';
import { HashLocationStrategy, LocationStrategy } from '@angular/common';
@NgModule({
imports: [
BrowserModule,
PainelModule,
SidebarModule,
NavbarModule,
FooterModule,
FormsModule,
ReactiveFormsModule,
RouterModule.forRoot([])
],
declarations: [ AppComponent, PainelComponent ],
providers: [{provide: LocationStrategy, useClass: HashLocationStrategy}],
bootstrap: [ AppComponent ]
})
export class AppModule { }
控制檯顯示如下:
Unhandled Promise rejection: Template parse errors:
Can't bind to 'ngModel' since it isn't a known property of 'input'. (""for="">RA <span class="star">*</span></label><input type="text" [ERROR ->][(ngModel)]="myModel" />{{myModel}}</"): [email protected]:51 ; Zone: <root> ; Task: Promise.then ; Value:
個app.component.ts
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import {Location, LocationStrategy, PathLocationStrategy} from '@angular/common';
@Component({
selector: 'my-app',
templateUrl: 'app/app.component.html'
})
export class AppComponent implements OnInit{
location: Location;
constructor(location:Location) {
this.location = location;
}
ngOnInit(){
$.getScript('dashboard.js');
}
public isMaps(path){
var titlee = this.location.prepareExternalUrl(this.location.path());
titlee = titlee.slice(1);
if(path === titlee){
return true;
}
else {
return false;
}
}
}
我試圖做一個測試,所以HTML頁面非常簡單
HTML頁面:
<div class="form-group">
<label class="control-label" for="">RA </label>
<input type="text" [(ngModel)]="myModel" />{{myModel}}</div>
該角的版本你正在努力基於myModel財產。你也可以發佈的HTML? – JEMI
我正在使用Angular 2.4.9 –