我已经使用javascript动态创建了一个按钮。
在该按钮上单击,我正在调用$(document).on(“单击”,function())。
在这个函数中,我试图更新else语句中的ng show值,但它没有更新。
下面是代码。
$(document).on("click", '#referencelink', function (event, e) {
debugger;
var i = 0;
var thisList = "";
var url = {
urlhtml1
};
//urls1.urlhtml1 = $(event.target).prev("input").find("#urlhtml1").val();
urls1.urlhtml1 = $(event.target).prev("input").val();
if (urls1.urlhtml1 != undefined && urls1.urlhtml1 != "") {
if (urls1.urlhtml1.substring(0, 4) == "www." && urls1.urlhtml1.substring(urls1.urlhtml1.length - 4) == ".com") {
//urls1.urlhtml1 = $(event.target).closest("tr").children('td:nth-child(4)').find("#urlhtml1").val();
var elem = document.createElement("button");
elem.className = "btn btn-info urllinkbutton1";
elem.setAttribute("id", "urllinkbutton1");
urlList.push(urls1.urlhtml1);
for (i = 0; i < urlList.length; i++) {
thisList += "<a class='btn btn-info' id='urllink1' target='blank' href='" + urlList[i] + "'>" + urlList[i] + "</a>";
elem.innerHTML = "" + urlList[i] + "<span id='removelink' class='fa fa-close'></span>";
$compile(elem)($scope);
$(this).closest("tr").children('td:nth-child(7)').find("#showurls1").append(elem);
}
$(event.target).prev("input").val('');
}
else {
//alert("Input is not valid, Please give a valid URL");
$scope.lblValidmsg = "Input is not valid, Please give a valid URL";
$timeout(function () { $scope.lblValidmsg = ""; }, 4000);
event.stopImmediatePropagation();
}
}
event.stopImmediatePropagation();
//return;
//e.stopPropagation();
});
暂无答案!
目前还没有任何答案,快来回答吧!