ryuKKu- / angular-particle

Particle.js rewritted for Angular2/4
56 stars 22 forks source link

Params isn't updating inside an Http Get subscription #9

Open StriderRanger opened 6 years ago

StriderRanger commented 6 years ago

Hello,

Thank you for sharing this solution.

I am facing an issue with getting parameters from a JSON file, instead of passing the parameters as an object in the typescript code. This is the content of my JSON file:

{
  "particles": {
    "number": {
      "value": 200
    },
    "color": {
      "value": "#ff0000"
    },
    "shape": {
      "type": "triangle"
    }
  }
}

and this is how I assign my params variable:

 //...
ngOnInit() {
    //...
    this.http.get("assets/particlesjs-config.json").subscribe(
        data => {
          this.params = data;
          console.log(this.params)
     });
  }

The console.log line prints the content of the json file in the console, but I can't in any way have the animation when I assign the params inside the Http Get subscription.

Thank you for your support