Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
切换开关更改标签文本并返回boolean Angular 11引导_Angular_Switch Statement_Label_Toggle - Fatal编程技术网

切换开关更改标签文本并返回boolean Angular 11引导

切换开关更改标签文本并返回boolean Angular 11引导,angular,switch-statement,label,toggle,Angular,Switch Statement,Label,Toggle,我想用现代的方式将我网站上的几个切换开关的状态更改为是或否 我没有找到一个现成的解决方案,所以我必须弄清楚如何正确地使用它 我有10个开关,它们必须返回一个单独的布尔值,并将它们的文本分别更改为“是”或“否”。如何做到这一点 这是我当前的代码,适用于1开关。(使用角度11中的引导5) 您可以创建开关切换组件并将其导入ShareModule import{Component,EventEmitter,Input,OnInit,Output,TemplateRef}来自“@angular/core

我想用现代的方式将我网站上的几个切换开关的状态更改为是或否

我没有找到一个现成的解决方案,所以我必须弄清楚如何正确地使用它

我有10个开关,它们必须返回一个单独的布尔值,并将它们的文本分别更改为“是”或“否”。如何做到这一点

这是我当前的代码,适用于1开关。(使用角度11中的引导5)


您可以创建开关切换组件并将其导入ShareModule

import{Component,EventEmitter,Input,OnInit,Output,TemplateRef}来自“@angular/core”;
@组成部分({
选择器:“开关切换”,
templateUrl:“./switch toggle.component.html”,
样式URL:[“/switch toggle.component.scss”]
})
导出类SwitchToggleComponent实现OnInit{
@Input()id?:字符串;
@Output()onChange:EventEmitter=neweventemitter();
值:布尔值;
构造函数(){}
ngOnInit(){}
设置值(值){
这个值=值;
emit({id:this.id,value:this.value});
}
}


改用数组?我不知道如何运行它,我还是一个角度方面的初学者。它显示了不同的错误:“错误TS7006:参数'value'隐式地具有'any'类型。”我还没有使用共享模块。在我的html中,doFunction是红色的。你能给我一个明确的例子,不使用共享模块而使用我的代码吗?查看此链接,希望对您有所帮助
   <div class="form-check form-switch">
      <input class="form-check-input" type="checkbox" (change)="isTrue()" id="flexSwitchCheckDefault">
      <label *ngIf="isTrue()" class="form-check-label" for="flexSwitchCheckDefault">Yes</label>
      <label *ngIf="isFalse()" class="form-check-label" for="flexSwitchCheckDefault">No</label>
    </div>
export class SComponent implements OnInit {

  status = true;

  constructor() {
  }

  ngOnInit(): void {
  }

  isTrue() {
    return this.status = !this.status;
  }

  isFalse() {
    return this.status === false;
  }

}