How To Use Winwheel.js Callback In Angular2
I have been working with a roulette design, where i need a wheel, so i am using winwheel.js library. wheel; wheelSpinning = false; constructor() { } ngAfterViewInit() {
Solution 1:
I ended up modifying the library Winwheel.js
at line 2266
to remove the eval function that parses the function string to a simple function callback:
eval(winwheelToDrawDuringAnimation.animation.callbackFinished);
to
winwheelToDrawDuringAnimation.animation.callbackFinished();
Then in your code
'callbackFinished': 'alertPrize()'
becomes 'callbackFinished': this.alertPrize.bind(this)
where I bind the component scope to the callback so that it can access component class properties and methods.
Perhaps a better way would have been to fork the git repo and make this change there but I didn't because the repo isn't on bower
or npm
.
Post a Comment for "How To Use Winwheel.js Callback In Angular2"