ではないので、私はブラウザでauthbox.component.ts角度2:それは角度2の成分で知られているネイティブのプロパティ
import {Component} from 'angular2/core';
import {COMMON_DIRECTIVES} from 'angular2/common';
import {Credentials} from './credentials'
@Component({
selector: 'authbox',
template: `<div>
<div class="login-panel" *NgIf="!IsLogged">
<input type="text" *NgModel="credentials.name" />
<input type="password" *NgModel="credentials.password" />
<button type="button" (click)="signIn(credentials)">→| Sign In</button>
</div>
<div class="logged-panel" *NgIf="IsLogged">
<span>{nickname}</span> <button type="button" (click)="signOut()">|→ Sign out</button>
</div>
</div>`,
directives: [COMMON_DIRECTIVES]
})
export class AuthBoxComponent {
private _isLogged: boolean;
get IsLogged(): boolean {
return this._isLogged
}
set IsLogged(value: boolean) {
this._isLogged = value;
}
public credentials: Credentials;
}
を持つXにバインドできません私ははバインドできません«エラーを得ました「NgModel」は既知のネイティブプロパティではないため、»および「」はNgIfにバインドできません。これは既知のネイティブプロパティではないため、»です。
私はむしろ代わりに、一般的には*NgIf
<span>{{nickname}}</span> <button type="button" (click)="signOut()">|→ Sign out</button>
export class AuthBoxComponent {
nickname="guest";
...
}
同じエラー。たぶん輸入品と何か? –
私は、angle2のドキュメントでバインディングシンタックスについて話していないと感じました... https://angular.io/docs/ts/latest/guide/template-syntax.html – Mitchapp