问题描述
我已经用angular2@2.0.0-alpha.11编写了一个简单的应用程序,并且效果很好.现在,我正在使用npm上可用的最新版本的alpha和beta对其进行测试,我一直想知道我是否真的真的更改过或者正在缓存某些内容.
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 keep wondering if I really really changed or I am caching something.
我想在根组件上执行以下操作
I want to do something like the below on my root component
export class ChromeComponent {
ngOnInit() {
console.log('angular version');
}
}
控制台上的
angular.version
返回undefined
推荐答案
自4.0.0-rc.1起更新
为DOM中的根选择器添加了版本
Version is added for root selector in the DOM
由于angular2版本 2.3.0-rc.0 ,您可以获得以下版本:
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
}
}
或者您也可以打开浏览器控制台并检查body
标签
Or you can just open browser console and check body
tag
这篇关于如何使用打字稿检查Angular2版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!