-3

I have an existing ASP.NET Web application that I am trying to add Angular views to. I found examples of how to start with a new project but not how to add it to an existing project.

Notes

  • .NetSDK 2.1
  • Visual Studio 2017
  • Everything is written in C# (and working), I am trying to add one Angular view as a proof of concept
Rilcon42
  • 9,584
  • 18
  • 83
  • 167
  • 3
    Why delete the [previous question](https://stackoverflow.com/q/51600260/1260204)? – Igor Jul 30 '18 at 18:53
  • 2
    Especially considering this question has the same problems the previous one did – BradleyDotNET Jul 30 '18 at 18:59
  • 1
    If you go to your project templates (File New Project), you should see an Angular template option if you have the latest version of VS 2017. – DeborahK Jul 30 '18 at 19:10
  • @Igor I deleted the previous question because the comments had me thinking it was as unsolvable issue with MVC, but solvable with a Web application. So I checked, and discovered the project is a Web app, not MVC like I originally stated – Rilcon42 Jul 30 '18 at 20:01
  • I don't know why people give negative here. People ask a lot of combine ASP and Angular and it seems no one have a good answer. – Ryan Huang Jul 30 '18 at 20:05
  • 1
    One of the problems is that there are *many* different ways to add Angular support to a Web application ... so there is no *one* right answer. I'm guessing that this may be voted down because it is not very detailed as to exactly what the OP needs. Is it VS 2017? Web forms? How does the Angular app need to work with the ASP.NET Web app (is it only Web API?) and so on. – DeborahK Jul 30 '18 at 20:11
  • 1
    The main complaint from before was `I attempted to simply copy files from the blank project into mine, but that broke things`. There is no mention on what you mean by "broke" and no shared code either. We (most of us) are not sure what it is you are trying to get to work. Is it that you can run the app? Is it not being called from a script tag? Is it not compiling? Is it not being built with the cli? The lack of detail is the main problem. – Igor Jul 30 '18 at 20:11
  • @DeborahK thanks for the suggestions. Any other details I can add that would help? – Rilcon42 Jul 30 '18 at 20:19

1 Answers1

3

Not sure I totally understand your issue, but that's how I do for my project. I have a .net mvc project that part of it (membership section) is using Angular. I add the Angular by these ways:

  1. create a separate Angular 6 project.
  2. Build the project by "ng build"
  3. In the "dist" folder these are four main Angular files: main.js, polyfills.js, runtime.js, style.css.
  4. Import those files into the ASP production project.
  5. In index.cshtml file, I use old school html js <script> tag and <style> and the most important Angular tag: <app-root></app-root>

That's all you need for adding the Angular and everything works find. This may bing a issue when you need to make change to the Angular project then rebuild those files again and import them. But I can't find any tutorial can solve my needs so far. Some people may have a better solution.

Addition: When you look into Angular builded index.html file, it does the same simple way and nothing complex in it.

Ryan Huang
  • 728
  • 6
  • 7