Angular 2 CLI在Visual Studio 2015中的集成 [英] Angular 2 cli integration in visual studio 2015
问题描述
我正在尝试使用angular2 cli设置在Visual Studio 2015中创建一个angular 2应用程序.
I am trying to create an angular 2 application in visual studio 2015 using angular2 cli setup.
我已经完成了以下步骤来设置项目
I have done the following steps to setup the project
-
执行以下安装cli的命令
Execute the following command that installs the cli
npm i -g angular-cli
执行以下创建文件和文件夹结构的命令
Execute the following command that creates file and folder structure
ng new projectname
执行以下命令来构建项目
Execute the following command that builds the project
ng serve
默认情况下,angular 2应用程序在端口4200上提供.因此,当我执行 http://localhost:4200 时,我可以看到在浏览器中提供了index.html页面.我知道它是通过ng服务器而不是IIS提供的.如果我错了,请纠正我.如果我复制文件夹和文件结构并将其包含在我的Visual Studio解决方案中并运行它,我会看到Visual Studio使用其自己的端口.即使我在项目属性中将端口设置为4200并尝试执行 http://localhost:4200 ,它也无法正常工作.我相信这是因为它现在由IIS托管,而IIS对此应用程序一无所知.有人可以告诉我如何进行实时设置吗?
By default the angular 2 app is served on port 4200. So when I execute the http://localhost:4200 , I can see the index.html page is served on the browser. I understand that it is served via ng server and not IIS. Please correct me if I am wrong. If i copy the folder and file structure and include in my visual studio solution and run it, I see that visual studio uses its own port. Even if I set the port to 4200 in the project properties and try and execute http://localhost:4200 , it doesent work. I believe it is because it is now being hosted by IIS and IIS has no clue of this application. Could somebody tell me how to go about setting it up in real time scenario
我基本上是想在html中进行更改,并使用Visual Studio 2015编辑器执行代码.我没有反映出任何变化
I am basically trying to make changes in the html and execute the code using visual studio 2015 editor. I dont any changes reflected
推荐答案
查看文件结构将很有帮助.听起来您只是将Visual Studio用作IDE.如果那是正确的话,我就不用担心使用绿色的播放按钮.您必须运行任务才能构建它,因此Task Runner将成为您的朋友.那或者只是打开控制台,然后从那里命令.
A view of your file structure would be helpful. It sounds like you're simply using Visual Studio as an IDE. If that is correct, I wouldn't worry about using the green play button. You have to run task for it to build, so Task Runner will be your friend. That or just open up console and do you commands from there.
我个人更喜欢只使用IDE,例如Visual Studio代码,但是如果您必须使用VS,那么我建议您使用下面的链接.
I personally prefer just using an IDE, like visual studio code, but if you must use VS, then I recommend the link below.
这是在Visual Studio中运行Angular 2项目而不将其放入ASP.NET项目的很好参考.
这篇关于Angular 2 CLI在Visual Studio 2015中的集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!