ASP.NET Core 2 Angular 模板中的 Angular CLI?

编程入门 行业动态 更新时间:2024-10-15 20:24:35
本文介绍了ASP.NET Core 2 Angular 模板中的 Angular CLI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我了解 Angular 和 ASP.NET Core 2 的基础知识,但没有达到可以让我理解该模板如何工作的水平.

I know the basics of Angular and ASP.NET Core 2, but not on the level that would allow me to understand how this template works.

我尝试在 Visual Studio Code 中使用 Angular CLI 生成组件,但是,它说我没有 CLI.我认为是 webpack 的东西保留了 CLI 并允许模板附带的所有很酷的东西,但是有没有办法使用 CLI?或者,例如,我是否通过创建文件和添加依赖项手动生成组件?

I tried generating components using Angular CLI in Visual Studio Code, however, it says I don't have the CLI. I think it's the webpack thingy that keeps the CLI and allows all the cool stuff that comes with the template, but is there a way to use the CLI despite that? Or do I have, for example, generate components manually by creating the files and adding dependecies?

我找不到有关模板的任何文档或使用它的教程.

I can't find any documentation on the template or a tutorial that would use it.

推荐答案

首先全局安装angular cli后:

First of all after installing angular cli globally:

npm install @angular/cli@latest -g

您必须首先使用以下命令在主项目之外创建一个 angular 项目:

You have to first create an angular project outside your main project with this command:

ng new hello-world

现在,转到项目目录并将 .angular-cli.json 文件复制到主 dot net core 项目的根目录中.然后你必须编辑文件的这一部分:

Now, go to project directory and copy .angular-cli.json file into the root of your main dot net core project. Then you have to edit this part of the file:

根": "src" 更改为 "root";:客户端应用程序"

接下来,您必须在项目的根目录中安装 angularCli dev:

Next, you have to install angularCli dev in your root of your project:

cd DotNetCoreProject

npm install @angular/cli@latest --save-dev

一切都完成了!

现在,转到项目的组件目录:

cd ClientApp/app/components

并在终端的组件目录中制作您的组件:

and make your component in component directory in terminal:

ng g c MyComponent --module='app.module.browser.ts'

更多推荐

ASP.NET Core 2 Angular 模板中的 Angular CLI?

本文发布于:2023-11-13 22:26:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585493.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模板   NET   ASP   Core   CLI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!