ASP.NET Core 2 Angular模板中的Angular CLI? [英] Angular CLI in ASP.NET Core 2 Angular template?

查看:84
本文介绍了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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆