【发布时间】:2018-03-23 10:49:44
【问题描述】:
在
中有一个叫做numbers的数组export class MyphotographsComponent implements OnInit {
numbers =[]
}
在“数字”数组之后我有 onNgInit(){}。在这有一个功能。通过这个函数,我想将一个变量推送到 NgOnInit 之外的数组中。我尝试了 'this.numbers.push[i]' 这很有效。在这方面需要一些帮助。
下面是我的示例代码
export class MyphotographsComponent implements OnInit {
numbers= [];
ngOnInit() {
function loadImages() {
this.numbers.push[1]
}
loadImages();
}
}
【问题讨论】:
标签: javascript angular angular-directive