Мне нужно передать массив с именем "photos" из моего component.ts в component.html.Вот мой файл component.ts
export class PhotosComponent implements OnInit {
public photos:any[]
constructor(){}
ngOnInit(){
S3.listObjects({Delimiter: '/'}, function(err, data) {
var albumName
if (err) {
return alert('There was an error listing your albums: ' + err.message);
} else {
console.log(data.CommonPrefixes)
var albums = data.CommonPrefixes.map(function(commonPrefix) {
// console.log(albums)
var prefix = commonPrefix.Prefix;
console.log(prefix)
albumName = decodeURIComponent(prefix.replace('/', ''));
console.log(albumName)
this.photos.push(albumName)
});
}
});
console.log(this.photos)
}
В строке this.photos.push (albumName) написано «Невозможно прочитать свойство 'photos' of undefined". Также я не могу передать данные в html.Любая помощь будет оценена.Заранее спасибо