[英]Directive: ngModel not change ng-hide
I started build a directive calendar and I have a problem: 我开始构建指令日历,但遇到了问题:
I'm putting dynamic tables and want to filter by a ngModel that is parent controller, but I can not take the change of ngModel using dynamic tables and attr. 我正在放置动态表,并希望通过作为父控制器的ngModel进行过滤,但是我无法使用动态表和attr进行ngModel的更改。
Here is the code: 这是代码:
HTML 的HTML
<li class="checkbox">
<input type="checkbox" ng-model="confirm.is_true" checked class="checked-blue">
<label>Confirm</label>
</li>
JS JS
function createBar(kind) {
var _span = document.createElement("div");
switch(kind){
case "initial":
var _img = document.createElement("img");
var _text = document.createTextNode("Test");
_img.src = "/uploads/photo/27/sq135_DSC_0011.JPG";
_span.appendChild(_img);
_span.appendChild(_text);
_span.className = "bar-init";
_span.setAttribute("ng-hide", "confirm.is_true");
break;
case "middle":
_span.className = "bar-middle";
break;
case "end":
_span.className = "bar-end";
break;
}
return _span;
}
Thanks 谢谢
The problem is, I think that angular is not aware of the fact that you are creating this element. 问题是,我认为angular不了解您正在创建此元素的事实。 You should definitely have a look into
$compile
method. 您绝对应该看一下
$compile
方法。 Instead of using document.createElement
use angular.element
. 代替使用
document.createElement
而是使用angular.element
。 After creating desired element, use $compile(_span)($scope)
. 创建所需的元素后,使用
$compile(_span)($scope)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.