启动Angular应用程序时出现以下错误,即使未显示该组件也是如此.
我必须注释掉,以便我的应用程序正常运行.
zone.js:461 Unhandled Promise rejection: Template parse errors:
Can't bind to 'ngModel' since it isn't a known property of 'input'. ("
<div>
<label>Created:</label>
<input type="text" [ERROR ->][(ngModel)]="test" placeholder="foo" />
</div>
</div>"): InterventionDetails@4:28 ; Zone: <root> ; Task: Promise.then ; Value:
Run Code Online (Sandbox Code Playgroud)
我正在看着英雄的掠夺者,但我没有看到任何区别.
这是组件文件:
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Intervention } from '../../model/intervention';
@Component({
selector: 'intervention-details',
templateUrl: 'app/intervention/details/intervention.details.html',
styleUrls: ['app/intervention/details/intervention.details.css']
})
export class InterventionDetails
{
@Input() intervention: Intervention;
public test : string = "toto"; …Run Code Online (Sandbox Code Playgroud) 鉴于此复选框:
<input type="checkbox" name="sendemail">
Run Code Online (Sandbox Code Playgroud)
如何检查 Angular 10 中是否已选中?
我找到了很多例子,但它们看起来对于检查值来说太复杂了。
谢谢。
在此处的文档中:http : //getbootstrap.com/docs/4.0/components/forms/#checkboxes-and-radios-1
从来没有提到如何正确使用自定义复选框,使用检查器似乎没有添加任何类,并且值始终为“ on”。
也没有提到如何通过html或javascript更改它们的状态。
JsFiddle:https ://jsfiddle.net/2n40w13k/1/
Js:
$('.custom-control-input').on('change', evt => {
console.log(evt.target.value);
})
Run Code Online (Sandbox Code Playgroud)