remove HTML element on click in Angular js

angularjs, html

Solution

You can simply create a directive, that adds a function that will remove the html of the element. Then you can just stick it on an ng-click. I made a fiddle here: http://jsfiddle.net/qDhT9/

// in the directive
scope.remove = function() {
    elt.html('');
};
// in the dom
<div remove-on-click ng-click="remove()"> 
    REMOVE ME 
</div>

Hope this helped!

Problem

This is my Directive. which display one Div on the body. ``` app.directive("autosuggest", function($rootScope) { return { scope: { doneFlag : "=", groupFlag : "=", inviteesFlag : "=", init: '&' }, templateUrl : "title.html", link: function(scope, element, attrs) { } }); ``` And in title.html ``` <div class="showw"> <img id="hideDivOnClick" src="ddd.png"/> </div> ``` And i include directive like this ``` <div autosuggest="" done-Flag="1" group-Flag="1" invitees-Flag="1" selected-Array="" ></div> ``` so when i click on image then this `<div autosuggest="" done-Flag="1" group-Flag="1" invitees-Flag="1" selected-Array="" ></div>` parts gets remove from body. like remove element in Javascript. how i will achive this in angularJS?

Original source