Лучший вариант, который я нашел, ниже. Он будет извлекать число и может устранить любой тип char.
def extract_nbr(input_str):
if input_str is None or input_str == '':
return 0
out_number = ''
for ele in input_str:
if ele.isdigit():
out_number += ele
return float(out_number)
Возможно, вы можете попробовать использовать currentTarget
, чтобы проверить, находится ли клик от привязки или нет
@HostListener('click', ['$event'])
onClick(event: MouseEvent) {
console.log(event.currentTarget); // You can put this as a IF condition
}
Надеюсь, что это поможет!
Это возможно сделать [императив]
@ViewChild('a') anchor:ElementRef;
clickHandler(event) {
console.log(event);
}
_clickHandler = this.clickHandler.bind(this);
ngAfterViewInit() {
this.anchor.nativeElement.addEventListener('click', this._clickHandler);
}
для отмены подписки на использование
this.anchor.nativeElement.removeEventListener('click', this._clickHandler);