I created an Angularjs directory for an inline editor. The HTML template is created by using function and compiling with the HTML root element. My problem is I want to change a status variable when I click on an element to achieve toggling, but it seems not to be working.
I've included the code snippets for reference, which is written inside a directive link function.
var appendTotemplate = function () {
var uploadMediaName = "hello";
var MediaNameEditable = false;
template = "<a ng-if='MediaNameEditable !=true' ng-click='MediaNameEditable=true'" + uploadMediaName + "</a>" +
"<input ng-if='MediaNameEditable==true' type='text' value='" + uploadMediaName + "' id='mediatxt' ng-click='MediaNameEditable=false;' >";
var linkFn = $compile(template);
var content = linkFn(scope);
element.append(content);
}();
Please check the code. I really want to implement this way. Thanks in advance!