我有一个通过ng-repeat构建的玉片段。
fieldset(data-ng-repeat='product in products track by $index')
input(type='text', ng-model='product.name', name='product.name', placeholder='Enter Product Id')
button.remove(type="button",ng-show='$last', ng-click='removeChoice()') -
button.validate(type="button",ng-click='validateProduct($index)') Validate
p(ng-bind-html="productResponse{{$index}}")
button.addfields(type="button",ng-click='addNewChoice()') Add fields
这是生成HTML
的角度函数$scope.validateProduct = function (e) {
//alert($scope.products[e].name);
$http.get("product?productId="+$scope.products[e].name)
.then(function(response) {
$scope['productResponse'+e] = response.data;
});
然而绑定失败..如果我设置静态名称i,我可以正确看到html绑定,e用productResponse替换productResponse {{$ index}}