I want to have a timestamp or build number somewhere on my Angular2 App so I can tell if a user is using an old cached version or not.
How to do this with AngularCLI
Add this step to your build (ie Jenkins-Job):
echo export class MyVersion {public static readonly number = '%SVN_REVISION%'} > src\my-version.ts
You can access the number like this:
import {MyVersion} from "../my-version";
export class AppComponent {
constructor() {
console.log("Welcome to MyApp version " + MyVersion.number);
}
}
This solution is + lightweight, + easy to read, + robust.