I have a directive, in which I click on a field and then I can edit it. To this directive I can add a property called "typeinput". If typeinput = "textarea" then I would like the dynamic field to be a textarea and not an input text. I'm doing this validation with the help of an ng-if.
But if I do this this stops working, and the new dynamic field value is not saved. How can i fix it?
<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>',
