Here data console and this data push in duplicatePushArray but it once pushed I dont want to push again but if I push again i want to show same message second time also.
Ex. first time I push 2.jpg,3.jpg now again I push 2.jpg,3.jpg so it shows message like this 2.jpg,3.jpg value is already pushed please change this values now again I push 2.jpg,3.jpg so it shows message like this 2.jpg,3.jpg,2.jpg,3.jpg value is already pushed please change this values but i want to show message like this 2.jpg,3.jpg value is already pushed please change this values
console.log(data); // (2) [{…}, {…}]0: {imageName: "2.jpg"}1: {imageName: "3.jpg"}
duplicatePushArray : any[] = [];
constructor(private snackBar : MatSnackBar) {}
for(var i = 0; i < data.length ; i++){
if(this.duplicatePushArray.indexOf(data[i].imageName)) {
this.duplicatePushArray.push(data[i].imageName);
this.snackBar.open(this.duplicatePushArray+' '+ 'value is already pushed please change this values', '',{
duration: 2000
})
}
}
if(this.duplicatePushArray.indexOf(data[i].imageName) === -1) {