1
在Angular 1.x中,您可以使用 angular.version
來確定運行系統中的當前版本。確定當前的Angular 2.x版本
角度2.x中是否有類似的東西?我搜索了ng
,ng.core
,ng.common
和ng.compiler
沒有任何運氣的物體。
在Angular 1.x中,您可以使用 angular.version
來確定運行系統中的當前版本。確定當前的Angular 2.x版本
角度2.x中是否有類似的東西?我搜索了ng
,ng.core
,ng.common
和ng.compiler
沒有任何運氣的物體。
從Angular 2.3.0-rc0及更高版本中包含的this commit開始,您可以使用來自@angular/core
的VERSION
常量。
import { Component, VERSION } from '@angular/core';
@Component({
selector: 'angular-version',
template: '<p>Version: {{version}}</p>'
})
export class VersionComponent {
version: string = VERSION.full;
}
如果你只需要獲得開發者工具的版本,你可以試試
document.querySelector('[ng-version]').getAttribute('ng-version')
或檢查app-root
元素。
也許看看'@ angular/upgrade'模塊。像這樣的東西可能在那裏。 – martin
Thx @Martin,但不幸的是它沒有。 – MEMark