I am new to Angularjs and I need some help.
What I want to achieve is an inline editable text
That will switch between text and an input box
So onClick text will switch out with an input box give it focus
and when there is a blur it will switch back to the values text of the input box
If I hack it together I could probably get it to work but
I want to do it the angularjs way
So thanks for any help in advance
This is what I have so far
var textToInput = angular.module('textToInput',[]);
textToInput.directive(
'textToInputBox',
function () {
return {
// template : '<input type="text" >{{ Value }}</input>',
// replace : false,
link : function (scope, element, attr) {
element.bind('click', function ()
{
$(this).parent().html('<input type="text" value="'+element[0].innerHTML+'" input-box-to-text />');
scope.$apply(function(){
return
})
//alert(element[0].innerHTML);
//alert(attr.bob);
});
}
};
}
);
textToInput.directive(
'inputBoxToText',
function () {
return {
// template : '<input type="text" >{{ Value }}</input>',
// replace : false,
link : function (scope, element, attr) {
element.bind('blur', function ()
{
// $(this).html('<div text-to-input-box>'+element[0].value+'</div>');
// scope.$apply(function(){
// return
// })
alert(element[0].innerHTML);
});
}
};
}
);
and here is the HTML
<div text-to-input-box> hello world </div>
and here is the app
var app = angular.module('app', [
'textToInput'
])
once again thanks :)