我如何知道我使用的是哪个版本的Angular ?

我试过:

angular --version
angular --v
angular -version
angular -v

但是没有找到get -bash: angular:命令

通过yeoman -version我知道我使用的是0.9.6

但是如何获得angularjs版本呢?


当前回答

1. ng --version (For checking Installed Angular Version in system)

2. npm --version (For checking Installed NPM Version in system) 

3. node --version (For checking Installed Node Version in system) 

其他回答

另一种方法是从@angular/core导入VERSION常量,然后转储到控制台:

console.log(VERSION.full); //5.2.11

适用于:

Angular 8参见docs Angular 7参见docs Angular 6参见文档。 Angular 5参见docs Angular 4参见docs

Angular 2和3不太确定。(如果有人能测试一下;网页不可用)


对于AngularJS 1。使用angular.version:

console.log(angular.version); //1.7.4

注意:下面只检查Angular-CLI的版本!!:

这两个命令都有效:

ng -v

or

ng v

你也可以检查package.json:

"dependencies": {
    "@angular/common": "^5.0.0",
    "@angular/compiler": "^5.0.0",
    "@angular/core": "^5.0.0",
    "@angular/forms": "^5.0.0",
    "@angular/http": "^5.0.0",
    "@angular/platform-browser": "^5.0.0",
    "@angular/platform-browser-dynamic": "^5.0.0",
    "@angular/router": "^5.0.0",
  }

(插入号^将更新到最新的主版本(第一个数字)。 ^4.3.0将匹配任何4.x。X版本包括4.4.0,但将推迟到5.0.0。 波浪号~匹配最近的次要版本(中间的数字)。 ~4.3.0将匹配所有4.3。X版本,但将错过4.4.0。)

你可以从终端使用angular 2之后的版本,

ng -v



    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.7.3
Node: 9.3.0
OS: linux x64
Angular: 5.2.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.7.3
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0
mohideen@root:~/apps/UI$ 

对于angular JS,你可以在angular- animation . JS文件中找到它,如下所示:

/** * AngularJS v1.4.8 * (c) 2010-2015谷歌,Inc. http://angularjs.org *授权:MIT * /