import { Component} from '@angular/core';
@Component({
selector: 'mail-box',
templateUrl: 'mailBox.component.html',
styleUrls: ['./style.css']
})
export class mailBoxComponent {
items = [1];
}
function add(i: number) {
if (i <= 10) {
addItem();
setTimeout(add, 3000);
}
}
function addItem() {
this.items.leght + 1;
}
я не силен в typescript
let items = [1];
add = (i) => {
if (i <= 10) {
setTimeout(() => addItem(i), 3000)
}
}
addItem = (item) => {
items = [...items, item]
//items = items.concat([item])
//items.push(item)
}
//проверить
test = () => {
console.log(items)
add(5)
add(6)
add(999)
console.log(items)
setTimeout(() => console.log(items), 3500)
}
test()
//Console:
//[1]
//[1]
//[1, 5, 6]