我在自定义组件中使用了ng4-autocomplete组件,并希望在自动完成下拉菜单关闭时检测更改。你能告诉我你是如何实现"closeAutocomplete“方法的吗?
这是我的location.component.html
<ng4geo-autocomplete (click)="showAutocomplete()"
[userSettings]="location"
(componentCallback)="componentCallback123($event)" placeholder=""
(closeAutocomplete)="closeAutocomplete($event)"
>
</ng4geo-autocomplete>下面是location.component.ts文件。
import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges} from '@angular/core';
@Component({
selector: 'mitra-location',
templateUrl: './location.component.html',
styleUrls: ['./location.component.scss']
})
export class LocationComponent implements OnInit {
@Input('location') location = '';
@Output('callback') callback = new EventEmitter<any>();
locationElem;
ngOnInit() {
this.locationElem = document.getElementById('geo-location');
}
closeAutocomplete(event) {
// Here i want to get this event
}
}This是此组件的文档链接。
谢谢!
发布于 2018-05-28 19:59:17
正如您在documentation中看到的,在ng4geo-autocomplete组件上没有定义closeAutocomplete() Output。
唯一定义的输出是componentCallback,您已经正确调用了它。您不能在组件上像这样调用closeAutocomplete,因为它不是组件的输出属性。
https://stackoverflow.com/questions/50565690
复制相似问题