src/app/ui/erasable-input/erasable-input.component.ts
selector | framadate-erasable-input |
styleUrls | ./erasable-input.component.scss |
templateUrl | ./erasable-input.component.html |
Methods |
Inputs |
Outputs |
constructor()
|
inputModel | |
inputModelChange | |
Type : EventEmitter
|
|
eraseInput |
eraseInput()
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
@Component({
selector: 'framadate-erasable-input',
templateUrl: './erasable-input.component.html',
styleUrls: ['./erasable-input.component.scss']
})
export class ErasableInputComponent implements OnInit {
@Output() inputModelChange = new EventEmitter();
@Input() inputModel;
constructor() {
}
ngOnInit() {
}
eraseInput() {
//
this.inputModelChange.emit('');
// TODO focus on other element
}
}
<button
class="erase btn btn--warning"
*ngIf='inputModel.length'
(click)="eraseInput()" >
<i class="fa fa-times" ></i >
</button >
./erasable-input.component.scss