gpt4 book ai didi

Angular 2 : Can't bind to x since it isn't a known native property

转载 作者:太空狗 更新时间:2023-10-29 16:46:45 24 4
gpt4 key购买 nike

<分区>

在 Angular 2 组件中我有 authbox.component.ts

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>&nbsp;&nbsp; <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;

}

在浏览器中我得到错误«无法绑定(bind)到'NgModel',因为它不是已知的原生属性»和«无法绑定(bind)到'NgIf',因为它是'一个已知的本土属性(property)»。

我正在使用测试版 8。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com