angular5,公共组件,radio,list
web前端-js教程本文给大家说一下Radio List的公共组件提取。
android chm 源码,vscode 写乱码,i33240装ubuntu,tomcat应用很慢,sqlite建表数量,qq一键登录插件下载失败怎么办,微内核架构前端框架,app爬虫完整代码,php建文件,网站seo代码优化,ecshop网站url加密,.net网页中视频本地播放器播放,后台easyui登录界面模板,jquery 页面平滑滚动,响应式网站管理系统源码,ichat聊天室 程序lzw
Radio List组件提取起来很方便,不想Checkbox那么复杂。android 系统裁剪源码,ubuntu 搭建yum仓库,tomcat的端口怎么修改,mac系统爬虫,如何用php开发框架,SEO老兵lzw
radio-list.component.ts方唯直播源码,vscode命令行快捷键,ubuntu 修改yum,Tomcat查不到停止日志,入门爬虫函数,php静态化设计,揭阳seo网络营销推广渠道lzw
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); }}
radio-list.component.html
在相关引用的module中注册
import { RadioListComponent } from '../components/radio-list/radio-list.component';export const routes = [ { path: '', component: xxxComponent, pathMatch: 'full' }];@NgModule({ imports: [...], declarations: [... , RadioListComponent , ...], providers: []})export class xxxModule { static routes = routes;}
对应的html中引用如下:
按照如上步骤,还缺少对应的selectChange($event):
selectChange(model: any) { this[model.name] = model.value; }