In the browser's developer console with angular 1 I used to type:
angular.version.full
But do not work for angular 2.
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>
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
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.
You can import the version of angular like this:
import {Version} from '@angular/core';
See this issue
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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.