Tuesday, November 5, 2019

A simpler, maybe too simple, alternative to using a module as a static service in Angular.

As opposed to this, something like this could live in a file by itself somewhere.

export class Redundant {
   public doubleUp(key: string):string {
      return key + key;
   }
}

 
 

You could import it where you need it as you would normally and then turn around and use it like this:

let song:string = "Daddy's little baby loves" + Redundant.doubleUp(" shortnin");

No comments:

Post a Comment