JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-2.5.0.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div ng-app="myApp" ng-controller="myCtrl">
<div class="wrapper">
<input type="text" placeholder="Search" ng-model="search.pregunta">
<uib-accordion close-others="true">
<div ng-repeat="faq in faqs | filter: search.pregunta">
<div class="col-sm-11" >
<div uib-accordion-group class="panel-default" is-open="faq.open">
<uib-accordion-heading >
<span ng-click="ignoreClick($event);" ><a href='' click-to-edit item="faq" ng-model='faq.pregunta' typeinput='textarea' ng-bind-html="faq.pregunta | highlight:search.pregunta" >{{faq.pregunta}}</a></span> <i class="pull-right glyphicon" ng-class="{'glyphicon-chevron-down': faq.open, 'glyphicon-chevron-right': !faq.open}"></i>
</uib-accordion-heading>
<span click-to-edit item="faq" ng-model="faq.respuesta" search="search">{{faq.respuesta}}</span>
</div>
</div>
</div>
</uib-accordion>
{{faqs}}
</div>
CSS
.templateRoot{
display: inline-block;
}
.hover-edit-trigger:hover{
border: 1px solid #dcdcdc;
border-radius: 4px;
}
.edit-button-group{
__border: 1px solid #dcdcdc;
border-top: none;
border-radius: 4px;
padding: 0px 3px 0px 3px;
}
.edit-button-group .glyphicon{
border: 1px solid #dcdcdc;
border-radius: 4px;
margin: 1px;
cursor: pointer;
}
.highlighted {
background: yellow
}
JavaScript
var app = angular.module("myApp", ['ui.bootstrap']);
app.controller("myCtrl", function($scope) {
$scope.faqs=[
{"pregunta": "pregunta1", "respuesta": "respuesta1", "open":true},
{"pregunta": "pregunta2", "respuesta": "respuesta2", "open":false},
{"pregunta": "pregunta3", "respuesta": "respuesta3", "open":false}
];
//prevent open accordion
$scope.ignoreClick = function($event) {
$event.stopPropagation();
$event.preventDefault();
}
})
.directive('clickToEdit', function($timeout,$compile) {
return {
require: 'ngModel',
scope: {
model: '=ngModel',
search: '='
},
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()" ng-bind-html="model | highlight:search.pregunta"></div>'+
'<span ng-if=tipo==true>'+
'<input class="inputText" type="text" ng-model="localModel.value" ng-enter="save()" ng-show="editState" />' +
'</span>'+
'<span ng-if=tipo==false>'+
'<textarea class="inputText" type="text" ng-model="localModel.value" 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>',
link: function (scope, element, attrs) {
scope.editState = false;
scope.localModel={};
if(attrs.typeinput=='textarea'){
...