0

i use angular 6 and rxjs.

i define data1 as a list of array.

let interestingFields = [ 'traitement','datedebut', 'datefin'];
this.ppssToDisplay.subscribe(ppsList => { 
  this.data1 = [
    interestingFields,
    ...ppsList.map(pps => interestingFields.map(field => pps[field]))
    ];
    console.log(this.data1);
});

But i must use data1 out the fonction;`

i try this.data2 = this.data1; But it doesn't work

console.log(this.data1); pps.component.ts:71 (4) [Array(3), Array(3), Array(3), Array(3)]
console.log(this.data2); undefined

How i can do ?

  • `this.data1 = data1` ? – Jonas Wilms Jul 05 '18 at 08:55
  • 2
    *"i try this.data1 = `const data1`; But it doesn't work"* -- read about the [`const`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const) JavaScript keyword. And remove the TypeScript tag from the question. There is no TypeScript into it. As it is now it is pure JavaScript. – axiac Jul 05 '18 at 08:57
  • @jonas I edit the question in order to you understand. thanks you –  Jul 05 '18 at 09:03
  • Are you performing your console.log(this.data2) inside the subscribe block, or outside of it? – rrd Jul 05 '18 at 09:04
  • outside, i want simply?? use this.data1 outside subscribe block... –  Jul 05 '18 at 09:08
  • @Jonas i don't understand the solve, can youhelp me ? –  Jul 05 '18 at 09:20

0 Answers0