数组项不添加,但替换当前项
array item not adding but replaces current item?
Attributes
.saveAttribute($scope.attribute, function() {
toastr.success('Attribute added successfully', 'Success');
$scope.modalInstance.dismiss();
var arr=[];
arr.push($scope.attribute.parentAttribute.id)
console.log(arr);
setTimeout(function () {
for( var i=$scope.arr.length-1;i>=0;i--)
{
angular.element(document.getElementById(arr[i])).click();
}
},1000);
当我按下按钮的 ID 来数组数组项时,它替换了当前的 ID... 如何修复它。我尝试将该数组声明带到外面,但没有奏效。请帮忙...
在$scope.attribute
上方声明var array
。
var arr=[];
Attributes
.saveAttribute($scope.attribute, function() {
toastr.success('Attribute added successfully', 'Success');
$scope.modalInstance.dismiss();
arr.push($scope.attribute.parentAttribute.id)
setTimeout(function () {
for( var i=$scope.arr.length-1;i>=0;i--)
{
angular.element(document.getElementById(arr[i])).click();
}
},1000);
});
console.log(arr);
数组应该是一个$scope
变量。
$scope.arr=[];
$scope.arr.push($scope.attribute.parentAttribute.id)
相关文章:
- 将url替换为链接,但添加了困难
- Firebase推送;t添加但替换(JavaScript)
- jQuery appendTo 替换元素而不是添加元素,如果正在添加的元素预先存在于列表中
- 用javascript添加类,而不是替换
- 将字符串添加到不区分大小写的 RegExp 中替换的事物开始
- JS添加到功能而不是替换为原型
- 用图像替换页面,而不是添加图像
- 匹配数字并在替换之前添加
- 用javascript替换文本中的几个字符串 - 如何添加更多变量
- 是否存在替换Javascript构造函数的问题'原型,而不是添加到原型中
- 将值添加到本地存储,而不是替换它
- 添加另一个变量后,正则表达式替换不起作用
- Opencart 过滤器添加 onclick 事件以替换提交按钮
- 数组项不添加,但替换当前项
- 使用 JavaScript 添加(而不是替换)CSS 类
- 用javascript / JQuery替换并添加包装器
- JS 中的正则表达式 - 添加要替换的匹配项
- 将 onfocus 和 onblur 函数替换或添加到 jQuery 函数中的文本框
- 带有更新按钮.js D3 将新数据添加到旧数据而不是替换旧数据
- 替换/添加字符串在js的文本区域