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的实例代码-创新互联
标题网址:http://www.jxjierui.cn/article/eddse.html


咨询
建站咨询
