import { Component, OnInit, ViewChild, ViewContainerRef, OnDestroy } from '@angular/core'; import { VerifyDetailService } from 'projects/verify-detail/src/public-api'; @Component({ selector: 'app-validator-demo', templateUrl: './validator-demo.component.html', styleUrls: ['./validator-demo.component.scss'] }) export class ValidatorDemoComponent implements OnInit, OnDestroy { errorList = [ { id:'111', title:'单据信息[销售组织]', msg:'字段值不能为空', type:'empty' }, { id:'222', title:'单据信息[销售组织]', msg:'字段值不能为空', type:'empty' }, { id:'333', title:'单据信息[销售组织]', msg:'字段值填写错误', type:'error' }, { id:'444', title:'单据信息[销售组织]', msg:'字段值填写问题', type:'test' }, { id:'111', title:'单据信息[销售组织]', msg:'字段值不能为空', type:'empty' }, { id:'222', title:'单据信息[销售组织]', msg:'字段值不能为空', type:'empty' }, { id:'333', title:'单据信息[销售组织]', msg:'字段值填写错误', type:'error' }, { id:'444', title:'单据信息[销售组织]', msg:'字段值填写问题', type:'test' }, { id:'111', title:'单据信息[销售组织]', msg:'字段值不能为空', type:'empty' }, { id:'222', title:'单据信息[销售组织]', msg:'字段值不能为空', type:'empty' }, { id:'333', title:'单据信息[销售组织]', msg:'字段值填写错误', type:'error' }, { id:'444', title:'单据信息[销售组织]', msg:'字段值填写问题', type:'test' } ] tabTypeList = [ { id:'111', type:'all', title:'全部' }, { id:'222', type:'error', title:'错填' }, { id:'333', type:'empty', title:'漏填' }, { id:'444', type:'special', title:'特殊' } ] @ViewChild('content') contentEl; verifyContainer; listclick; showchange; constructor( private verifySer:VerifyDetailService) { } ngOnInit() { } // listclick(item){ // console.log(item); // } // showchange($event){ // console.log('当前显示状态为:'+ $event); // } create(){ //this.verifySer.createVerify(this.container,this.errorList,this.tabTypeList); this.verifyContainer = this.verifySer.createVerify({ 'parent':this.contentEl, 'verifyList':this.errorList, // 'verifyType':this.tabTypeList, //'showType':'empty', 'showList':true }); this.listclick = this.verifyContainer.validatorClick.subscribe(e=>{ console.log(e); }); this.showchange = this.verifyContainer.listshowChange.subscribe(e=>{ console.log(e); }) } clear(){ this.verifySer.clear(); } ngOnDestroy() { //debugger //this.verifySer.clear(); } }