Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用$compile angujar.js时出错_Javascript_Html_Angularjs_Pug - Fatal编程技术网

Javascript 使用$compile angujar.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

我在angular.js上做一个项目。我在编译时遇到问题

在以前版本的程序中,它显示了带有数据的表格(当
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);