Angular 6 checkbox thế nào

Mình có đoạn code sau :slight_smile:


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

@Component({
  selector: 'product',
  template:
  `
    <div class="box2">
      <div>this is {{ten}} component</div>
      <div>{{hs | json}}</div>
      ten :hs.ten<br>
      phai_nam :<input type="checkbox" [(ngModel)]="hs.phai_nam" /><br>
      co_vo :<input type="checkbox" [(ngModel)]="hs.co_vo" /><br>
    </div>
  `,
  styles: [
    '.box{border:1px solid blue}',
    '.box2{border:1px solid green;padding:5px;margin:5px;}'
  ]
})
export class ProductComponent implements OnInit {
  @Input() id: number;
  ten = "product";
  hs={
    ten:"thuc",
    phai_nam:true,
    co_vo:1,
  }
  constructor() { }
  ngOnInit() {
  }
}


Cái field phai_nam thì ok nhận 2 giá trị true, false
Còn cái field co_vo mình muốn cặp giá trị 1,0 thì làm sao?
mong ace giúp đỡ!!!

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?