In Angular 1.x you can determine the current version in runtime using
angular.version.
Is there anything similar in angular 2.x? I have searched the ng, ng.core, ng.common and ng.compiler objects without any luck.
As of this commit included in Angular 2.3.0-rc0 and up, you can use the VERSION const from @angular/core.
import { Component, VERSION } from '@angular/core';
@Component({
selector: 'angular-version',
template: '<p>Version: {{version}}</p>'
})
export class VersionComponent {
version: string = VERSION.full;
}
If you just need to get the version in the dev tools, try something like
document.querySelector('[ng-version]').getAttribute('ng-version')
or inspect the app-root element.
@angular/upgrademodule. Something like this could be there.