I am quite new to AngularJS and I am currently trying to figure out how to best approach this functionality:
I am looking for a way where I have something along the lines of <span editable>I am a text</span>, and when the user clicks on it, it becomes editable (eg. <input type="text">) until the element loses focus, at which point it should flip back to its original <span editable>...</span> with the new value. Furthermore, this is likely not static text but bound to a model.
I am thinking this should be doable with directives, but I've hit a road block along the line as to how such a directive would actually work.
app.directive('editable', function() {
return function(scope, element, attrs) {
element.bind('click', function () {
// something.
});
}
})
Can anyone provide me with guidance or a solution to this?
Thanks in advance,
- Manny