switch the content attribute to true with the click of a button to edit the text of the element and, when blurred, switch the content attribute to false when editing!
how to set contenteditable to false!
import {Component} from 'angular2/core'
@Component({
selector: 'my-app',
template: `
<h2 #el contenteditable="false" (blur)="text=el.textContent">
This Content is Editable
</h2>
<button (click)="toggleContenteditable()">Edit Text Content</button>
<hr/>
<p> Text Obj: {{text}}</p>
`
})
export class App {
text : string;
contenteditable:bool = false;
toggleContenteditable(){
this.contenteditable = !this.contenteditable;
}
}
source
share