Javascript 使用AngularJS在.append中进行数据绑定
我使用这段代码创建了一个表单,但我有一个输入,其中ng model设置为value,我需要在该TD上用{{}打印该值: angular.elementdocument.getElementById'space-for-table'.append<td{{value}}/td 我这样做是因为我需要在屏幕上打印HTML代码,这就是为什么我使用而不是来处理新元素中的模板和指令:Javascript 使用AngularJS在.append中进行数据绑定,javascript,html,angularjs,Javascript,Html,Angularjs,我使用这段代码创建了一个表单,但我有一个输入,其中ng model设置为value,我需要在该TD上用{{}打印该值: angular.elementdocument.getElementById'space-for-table'.append<td{{value}}/td 我这样做是因为我需要在屏幕上打印HTML代码,这就是为什么我使用而不是来处理新元素中的模板和指令: $compile(newElement)(scope); 角度。模块'app',[] .runfunction$ro
$compile(newElement)(scope);
角度。模块'app',[]
.runfunction$rootScope$compile{
$rootScope.value=123;
var newElem=document.createTextNode{{value};
document.getElementById'target'.appendChildnewElem;
//重要部分:
$compilenewElem$rootScope;
$rootScope.$apply;
}
你能摆弄一下到目前为止你所拥有的,并展示一下你所缺少的吗?这样更容易解决问题。不幸的是,这是一个实习生项目,所以在公共场合发布它是不安全的。但我会尝试分享其中的一部分。我尝试使用&compile,但它似乎无法在同一个函数下使用两个&compile。例如:geradorTable.directiveaddbuttons、函数$compile{return functionscope、元素、属性{element.bindclick、函数{scope.count++;angular.elementdocument.getElementById'space-for-first'。追加$compile第一个值scope;angular.elementdocument.getElementById'space-for-table-first'。追加和编译Testscope;scope.countresultado=0;};};};如果我删除seconds angular.element is works,但我需要通过相同的单击将内容添加到这两个DIV中。看起来像是打字错误,&compile->$compileOw,这是真的。现在它可以打印两个代码,但我仍然无法打印@euDennis,我认为在angular可以正确打印它之前,您需要先转义。