angular - 单击复选框后如何更改标题
问题描述
这是我的片段:
import { Component, OnInit, Output } from '@angular/core';
import { EventEmitter } from 'events';
@Component({
selector: 'app-captcha',
templateUrl: './captcha.component.html',
styleUrls: ['./captcha.component.css']
})
export class CaptchaComponent implements OnInit {
captcha="click case for change title";
peut:boolean=true;
oui:boolean=true;
nom:boolean=true;
constructor() { }
ngOnInit() {
}
cocher(){
console.log(this.peut,"**");
if(this.peut === false){ this.captcha == "title is changed!"};
}
}
<h2 [(ngModel)]="captcha">{{captcha}}</h2>
<div>
<mat-checkbox [(ngModel)]="peut" (change)="cocher()" >peut-être ?</mat-checkbox>
<mat-checkbox [(ngModel)]="oui" (change)="cocher()" >oui ?</mat-checkbox>
<mat-checkbox [(ngModel)]="non" (change)="cocher()">non ?</mat-checkbox>
</div>
我必须如何正确加载标题。我有一个错误的萤火虫:错误错误:没有未指定名称属性的表单控件的值访问器
谢谢您的回复
解决方案
像这样更改此功能的代码
cocher(){
console.log(this.peut,"**");
if(!this.peut){
this.captcha ="title is changed!";
}
}
推荐阅读
- laravel - 错误:对于 mysql,需要一个类似字节的对象,而不是使用 docker-compose 和 laravelsai 的“str”
- batch-file - 创建批处理脚本以将特定文件从一个文件夹复制到另一个文件夹
- javascript - 我正在使用反应钩子 useEffect 来获取建议 api。每次刷新页面后它都会自动更改我如何使用按钮自动更改
- python-3.x - Odoo 12:访问先前计算的规则数量字段
- kotlin - 多个按钮的 OnClickListener 不起作用
- bash - Bash 脚本:将字符串编码为 base64 到变量中
- python - 如何上传存储在内存中的文件?
- r - 使用 facet_zoom 放大时间序列图
- python - sklearn LinearDiscriminantAnalysis 中的先验顺序
- amazon-web-services - Serverless 创建的 AWS Cognito 不发送确认电子邮件