Javascript 使用$compile angujar.js时出错
我在angular.js上做一个项目。我在编译时遇到问题 在以前版本的程序中,它显示了带有数据的表格(当Javascript 使用$compile angujar.js时出错,javascript,html,angularjs,pug,Javascript,Html,Angularjs,Pug,我在angular.js上做一个项目。我在编译时遇到问题 在以前版本的程序中,它显示了带有数据的表格(当currentProduct是单个变量时)。但是现在我使用的是一个数组,这个数组编译得不好 它和它有什么关系吗,曾经是一个普通变量,现在是一个变量数组 错误: 我正在使用此方法添加一个新div // trae los datos de la tabla Product.getPriceTable({id:product.id},function (result) { product.ha
currentProduct
是单个变量时)。但是现在我使用的是一个数组,这个数组编译得不好
它和它有什么关系吗,曾经是一个普通变量,现在是一个变量数组
错误:
我正在使用此方法添加一个新div
// trae los datos de la tabla
Product.getPriceTable({id:product.id},function (result) {
product.hasPriceTable = true;
product.priceTable = result.priceTable;
var directive = '<div editable-price-table price-table="currentProduct[product.id].priceTable" product="currentProduct[product.id]" user="currentUser" />';
var linkFn = $compile(directive);
var content = linkFn($scope);
angular.element('#price-table-' + product.id).append(content);
});
您能否显示
产品的申报位置?它是否附加到范围?这是向页面添加新内容的可怕方式。您应该针对数据编程,而不是使用angular针对DOM编程。使用ng repeat
,ng if
,或类似方法来允许angular处理DOM。以这种方式添加内容是JQuery的思维方式代码>
var linkFn = $compile(directive);