Reputation: 1079
In the browser's developer console with angular 1 I used to type:
angular.version.full
But do not work for angular 2.
Upvotes: 2
Views: 6956
Reputation: 164
The following piece of code works well:
import {Component, VERSION} from '@angular/core';
@Component({
selector: 'angular-version',
template: `Version: {{version.full}}`
})
export class AngularVersionComponent {
version = VERSION
}
Upvotes: 0
Reputation: 132
if you have the angular cli, you can do ng --version
which will return something along the lines of:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
@angular/cli: 1.2.0
node: 8.1.3
os: darwin x64
@angular/animations: 4.2.5
@angular/common: 4.2.5
@angular/compiler: 4.2.5
@angular/core: 4.2.5
@angular/forms: 4.2.5
@angular/http: 4.2.5
@angular/material: 2.0.0-beta.7
@angular/platform-browser: 4.2.5
@angular/platform-browser-dynamic: 4.2.5
@angular/router: 4.2.5
@angular/cli: 1.2.0
@angular/compiler-cli: 4.2.5
@angular/language-service: 4.2.5
Upvotes: 4
Reputation: 5391
you can see in packages.json your angular version.
"@angular/common": "2.3.1",
"@angular/compiler": "2.3.1",
"@angular/core": "2.3.1",
"@angular/forms": "2.3.1",
"@angular/http": "2.3.1",
"@angular/platform-browser": "2.3.1",
"@angular/platform-browser-dynamic": "2.3.1",
"@angular/router": "3.3.1"
if you have ^ before the version and run npm install command so you have the last angular 2 version.
Upvotes: 3
Reputation: 696
Agree Kévin Lemele.
The other way is the root component in your html has a attribute of ng-version
.
Like this.
<app ng-version="2.3.0"></app>
Upvotes: 5
Reputation: 46
You can import the version of angular like this:
import {Version} from '@angular/core';
See this issue
Upvotes: 2