Skip to content

Instantly share code, notes, and snippets.

@matthieu-D
Created June 25, 2016 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthieu-D/ad30589cd3b31f07807faf094f0aee45 to your computer and use it in GitHub Desktop.
Save matthieu-D/ad30589cd3b31f07807faf094f0aee45 to your computer and use it in GitHub Desktop.
import {Component, Input} from '@angular/core';
@Component({ selector: 'editable-text', template:`
<span *ngIf='isEditable'> <input type='text' (blur)="setEditable(false)" [(ngModel)]='node.text'> </span>
<span *ngIf='!isEditable' (click)='setEditable(true)'> {{node.text}} </span>
`
})
export class XEditableText {
@Input() node;
isEditable:boolean;
constructor() {}
setEditable (isEditable){
this.isEditable = isEditable;
}
ngOnInit(){
this.isEditable = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment