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

编程入门 行业动态 更新时间:2024-10-15 22:25:18
本文介绍了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

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

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

ng new hello-world

现在,转到项目目录,然后将.angular-cli.json文件复制到主点网核心项目的根目录中. 然后,您必须编辑文件的这一部分:

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:

"root" : "src"更改为"root" : "ClientApp"

接下来,您必须在项目的根目录中安装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:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585492.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模板   NET   ASP   Core   CLI

发布评论

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

>www.elefans.com

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