问题描述
这是我的指令。这对身体表示1事业部。
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) {
}
});
和在title.html
And in title.html
<div class="showw">
<img id="hideDivOnClick" src="ddd.png"/>
</div>
和我include指令像这样
And i include directive like this
<div autosuggest="" done-Flag="1" group-Flag="1" invitees-Flag="1" selected-Array="" ></div>
所以当我点击图像,然后这个&LT; DIV自动提示=完成标志=1组标志=1被邀请者标志=1选择阵= &GT;&LT; / DIV&GT;
部分会从体内取出。像在Javascript中删除元素。我怎么会在angularJS achive呢?
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?
推荐答案
您可以简单地创建一个指令,增加了一个功能,将删除元素的HTML。然后,你可以把它贴在了NG-点击。我在这里做了一个小提琴:
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>
希望这有助于!
这篇关于取消对点击的角JS HTML元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!