How to check Angular2 version with typescript

后端 未结 4 1744
礼貌的吻别
礼貌的吻别 2020-12-15 04:33

I have written a simple app with angular2@2.0.0-alpha.11, and it works great. Now that I am testing it with the latest version of the alpha and beta avaible on npm, and I ke

相关标签:
4条回答
  • 2020-12-15 04:53

    New answer since accepted one no longer the case on stable angular releases, easiest way to check angular version is to do so with npm list command at project root:

    npm list  @angular/core
    

    Just in case you can check following as well, versions should match:

    npm list @angular/common
    
    npm list @angular/compiler
    
    0 讨论(0)
  • 2020-12-15 04:58

    Update since 4.0.0-rc.1

    Version is added for root selector in the DOM

    Since angular2 version 2.3.0-rc.0 you can get version as follows:

    import { VERSION } from '@angular/core';
    
    export class AppComponent { 
      constructor() {
        console.log(VERSION.full); // print 2.3.0-rc.0
      }
    }
    

    Or you can just open browser console and check body tag

    0 讨论(0)
  • 2020-12-15 04:59

    The fact that current angular 2 is beta 13 combined with a simple search : https://github.com/angular/angular/search?l=typescript&p=1&q=13&type=Code&utf8=%E2%9C%93 and a look through docs https://angular.io/docs/ts/latest/api/ means that its not exposed at runtime as a simple version number

    Feel free to request it as a feature here : https://github.com/angular/angular/issues

    0 讨论(0)
  • 2020-12-15 05:12

    ng -v shows version of cli, node, os & angular.

    0 讨论(0)
提交回复
热议问题