1

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.

2
  • Maybe have a look inside @angular/upgrade module. Something like this could be there. Commented Sep 7, 2016 at 7:48
  • Thx @Martin, but unfontunately it didn't. Commented Sep 9, 2016 at 13:43

1 Answer 1

2

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;
}

Live example

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.