import {Component, OnInit, forwardRef} from '@angular/core'; import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms'; import UtilService from "@common/services/util"; import BaiduMap, {BaiduMapContext} from '@common/modals/baiduMap'; @Component({ selector: 'baiduMapPoint', templateUrl: './template.html', styleUrls: ['./style.less'], providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => BaiduMapPoint), multi: true }] }) export default class BaiduMapPoint implements OnInit { private onValueChange: any; point: any = {}; data: any = {}; constructor(private utilService: UtilService) { } ngOnInit(): void { } writeValue(value: any): void { this.point = value || {}; } registerOnChange(changeFn: any): void { this.onValueChange = changeFn; } registerOnTouched(changeFn: any): void { } selectPoint() { this.utilService.showModal(BaiduMap, BaiduMapContext, { point: this.point, callback: this.setPoint.bind(this) }) } setPoint(point) { this.onValueChange(point); this.point = point; } }