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

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

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