Angular5中提取公共组件之radiolist的实例代码-创新互联
                                            本文给大家说一下Radio List的公共组件提取。

Radio List组件提取起来很方便,不想Checkbox那么复杂。
radio-list.component.ts
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { RadioItem } from '../../model/radio';
import { NgModel } from '@angular/forms';
@Component({
  selector: 'app-radio-list',
  templateUrl: './radio-list.component.html',
  styleUrls: ['./radio-list.component.css']
})
export class RadioListComponent implements OnInit {
  @Input() list: RadioItem[];
  @Input() name: string;
  @Input() colNum: number = 6;
  @Input("selectModel") model: string;
  @Output("selectChange") onChange: EventEmitter = new EventEmitter();
  constructor() { }
  ngOnInit() {
  }
  changeSelected() {
    let data = { value: this.model, name: this.name };
    this.onChange.emit(data);
  }
}                                                  新闻标题:Angular5中提取公共组件之radiolist的实例代码-创新互联
文章URL:http://www.scyingshan.cn/article/eddse.html

 建站
建站
 咨询
咨询 售后
售后
 建站咨询
建站咨询 
 