应用程序池添加版本_如何将版本添加到角度应用程序

应用程序池添加版本

角度的 (Angular)

In this article, I will share a simple configuration to import the package.json file into your Angular application.

在本文中,我将分享一个简单的配置,将package.json文件导入您的Angular应用程序。

  1. Import @types/node

    导入@ types / node
  2. Add configuration to tsconfig.app.json

    将配置添加到tsconfig.app.json
  3. Import package.json to Angular component

    将package.json导入Angular组件

The purpose of this is very simple. Sometimes, we want to import package.json to Angular components to get the version number and display in the template.

这样的目的很简单。 有时,我们想将package.json导入Angular组件以获取版本号并显示在模板中。

Here is how I do it.

这是我的方法。

导入@ types / node (Import @types/node)

This package contains type definitions for Node.js. It will help you to recognize node syntax.

该软件包包含Node.js的类型定义。 这将帮助您识别节点语法。

You can install it here.

您可以在这里安装它。

将配置添加到tsconfig.app.json (Add Configuration to tsconfig.app.json)

You need node types in the tsconfig.app.json as below.

您需要在tsconfig.app.json中添加以下node类型。

应用程序池添加版本_如何将版本添加到角度应用程序
add node to tsconfig.app.json
将节点添加到tsconfig.app.json

将Package.json导入Angular组件 (Import Package.json to Angular Component)

The reason why I add @type/node here is that I want to use the require() syntax to import package.json to my Angular component.

我在此处添加@type/node的原因是我想使用require()语法将package.json导入到我的Angular组件中。

I have tried by using import. But, it is not successful for Angular application.

我已经尝试通过使用import 。 但是,它对于Angular应用程序并不成功。

应用程序池添加版本_如何将版本添加到角度应用程序
import package json to Angular component
将包json导入Angular组件

Now we can put the version into html template and use it.

现在我们可以将版本放入html模板并使用它。

I hope you found this article useful! You can follow me on Medium. I am also on Twitter. Feel free to leave any questions in the comments below. I’ll be glad to help out!

希望您觉得这篇文章有用! 您可以在Medium上关注我。 我也在Twitter上 。 随时在下面的评论中留下任何问题。 我很乐意提供帮助!

翻译自: https://levelup.gitconnected.com/how-to-add-version-to-angular-application-610c47201c7f

应用程序池添加版本