Normal CheckBox Example in Angular Framework

0
Normal CheckBox Example in Angular Framework:-

Create Component for normal CheckBox Example

Code of design file

<input type="checkbox" name="chk1" [(ngModel)]="chk1" value="C">C
<input type="checkbox" name="chk2" [(ngModel)]="chk2" value="CPP">CPP
<input type="button" name="btnclick2" value="Click" (click)="showcheck()">

{{res}}


Code of typescript file

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-factapp',
  templateUrl: './factapp.component.html',
  styleUrls: ['./factapp.component.css']
})
export class FactappComponent implements OnInit {
  s=''
  res=''
  chk1=''
  chk2=''
  res2=''
  
  constructor() { 

     
  }

  ngOnInit() {
  }
  
  showcheck(){
     this.res=''
    if(this.chk1)
    this.res +=  'C'+'' "
    if(this.chk2)
    this.res +=  'CPP'+'' "
   
  }
}



Post a Comment

0Comments

POST Answer of Questions and ASK to Doubt

Post a Comment (0)