
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { AppEnvironment } from 'src/environments/AppEnvironment';

@Component({
  selector: 'app-withtitle-list',
  templateUrl: './app-withtitle-list.component.html',
  styleUrls: ['./app-withtitle-list.component.scss'],
})
export class AppWithtitleList implements OnInit {

  /**
  * 基础路径
  */
  url: String = AppEnvironment.BaseUrl + AppEnvironment.ExportFile + '/';

  public _items:Array<any> =[];

  @Input() public title:string;

  /**
   * 输入属性
   */
  @Input() set items(val:any){
    if(val){
      this._items = JSON.parse(JSON.stringify(val));
      if(this._items.length >0){
        this._items.forEach((item:any) =>{
          if(item.image){
            item.image = JSON.parse(item.image);
          }
        })
      }
    }
  }

    /**
    * 抛出数据
    */
   @Output() itemClick: EventEmitter<any> = new EventEmitter<any>();

  constructor() { }

  ngOnInit() { }

  handleClick(item: any) {
    this.itemClick.emit(item);
  }

}
