Looking to make a directive where clicking on a field allows for editing. I want to be able to specify the type of input, such as "textarea" instead of just an input text field. Currently using ng-if for this validation.
https://i.sstatic.net/NAPbj.jpg
However, when I try to implement this, the new dynamic field value is not being saved. How can I troubleshoot this issue?
<div ng-repeat="faq in faqs">
<a href='' click-to-edit ng-model='faq.pregunta' typeinput='textarea' >{{faq.pregunta}}</a>
</div>
.directive('clickToEdit', function($timeout,$compile) {
return {
require: 'ngModel',
scope: {
model: '=ngModel'
},
replace: true,
transclude: false,
// includes our template
template:
'<div class="templateRoot">'+
'<div class="hover-edit-trigger" title="click to edit">'+
'<div class="hover-text-field" ng-show="!editState" ng-click="toggle()">{{model}}</div>'+
//'<span ng-if="type==true">'+
'<input class="inputText" type="text" ng-model="localModel" ng-enter="save()" ng-show="editState" />' +
//'</span>'+
//'<span ng-if="type==false">'+
//'<textarea class="inputText" ng-model="localModel" ng-enter="save()" ng-show="editState" />' +
//'</span>'+
'<div class="edit-button-group pull-right" ng-show="editState">'+
'<div class="glyphicon glyphicon-ok" ng-click="save()"></div>'+
'<div class="glyphicon glyphicon-remove" ng-click="cancel()"></div>'+
'</div>'+
'</div>'+
'</div>',