Skip to content Skip to sidebar Skip to footer

Passing A JS-Class To AngularJS(1.4.x) Service To Use Its Variables And Functions

I use angularJS(1.4) for frontend only. I have passed the JS-class DummyClass to an angularJS-Service called TLSService, and I added this service to an angularJS-Controller named m

Solution 1:

A problem in your original setup is when you register your class as a service, you're not returning the instance of the class:

function(){new DummyClass()}

Should be:

function(){return new DummyClass()}

Autoreturning only works when you don't use curly braces, like

() => new DummyClass()

Post a Comment for "Passing A JS-Class To AngularJS(1.4.x) Service To Use Its Variables And Functions"