首先,我知道angularjs并不是以这种方式使用,但我总是以这种方式使用它:)
其次,我刚刚问过this question并在2天前得到答案,但它不适用于ng-show指令。
有一个列表和一组具有ng-show指令的div,如果某些值不等于list的值,则每个div都隐藏em。这一切都是硬编码的 - 再次我知道我不应该为此使用angularjs
public void setPerformancePreferences(int connectionTime,
int latency,
int bandwidth)
{
/* Not implemented yet */
}
有一个上传图像的js函数,然后在其自己的div中添加DOM,并使用特定的<select ng-model="selected_album">
<option value="1">Album 1</option>
<option value="2">Album 2</option>
....
<div ng-show="selected_album == 1">.....
<div ng-show="selected_album == 1">.....
<div ng-show="selected_album == 1">.....
<div ng-show="selected_album == 2">.....
.....
指令,如
ng-show="selected_album == CURRENT_SELECTED_INDEX"
即使新的div中的元素的$scope.upload = function(files){
.....
// after upload progress below is the part that creates and adds the div
var div_new = document.createElement("div");
div_new.className = "overlay_thumb";
div_new.setAttribute("ng-show", ("selected_album == " + selected_index));
div_new.innerHTML = 'stuff';
div_some.parentNode.insertBefore(div_new, div_some.nextSibling);
$compile(div_new)($scope);
// there is no fail until here. div is being added to DOM just fine
// but angularjs is adding ng-shide to it directly i dont know why so
// i wrote this to remove ng-hide from it
$timeout(function(){ div_new.classList.remove("ng-hide"); },200);
....
}
指令正在工作,但对于div而言不是ng-click
。如何使它工作?