I'm trying to initialise Arrays variables from another Array in Angular2. Let me explain in details. Once I load my page, I receive from my server an Arrays containing strings (let's call it initialArray). And I would like to initialise Arrays variables (which I can use for after in my component), which are empty and which i can call for use after. I would like initialArray.length number of arrays. I don't know how can I achieve that
mycomponent.ts
import {Component} from '@angular/core' ;
import {getArrayService} from 'getarray.service';
@Component({
selector : 'mycomponent',
moduleId: module.id,
templateUrl: 'mycomponent.component.html'
})
export class myComponent{
initialArray : Array<string>
constructor(private _getarrayservice : getArrayService)
ngOnInit(){
this._getarrayservice.getArrayfromAPI()
.subscribe ( res => this.array = res,
err => console.error(err.status)
);
for(let name in initialArray ){
name : Array<any>;
};
}
}
However, this code isn't working because name is an array...