我想问下 。。 比如 : 点击按钮 生成 一段html代码。现在是 我想在这段html 加上directive指令 ,并且 加个 click事件,但是没效果。 click事件没效果。要怎么做啊?
app.directive("sadsdas",function(){
return {
restrict : "A",
link : function(scope,element,attrs){
element.on("click",function () {
console.log("sdsd")
});
}
}
})
app.directive("itemPopover",function($timeout){
return {
restrict : "A",
link : function(scope,element,attrs){
element.popover();
var createText = "<div class='hover' sadsdas style='position:absolute;top:50%;left:125px;width:400px;z-index:9999999;font-size:26px;color:#fff;text-align:center;'>请输入文本</div>";
var con = angular.element(".app-content");
element.on("click",function(){
if(attrs.tag == "createText"){
console.log(con)
$timeout(function(){
con.append(createText);
});
}
});
}
}
});
现在点击 sadsdas 的div 没输出 console.log("sdsd")
事件委托