2

I am trying to find out if there is a way to add a piece of Angular in a project built on different framework..

To be more specific, I have a .NET MVC project (Razor for the markup) from which I want to make some ajax calls and update bits of the UI. I rejected JQuery so far since I want to use a more modern approach(I am considering vanilla or vue because of the easy learning curve).

I thought the solution would be given by Angular Elements so I could have something like:

<my-popup message="Use Angular!"></my-popup>

but it doesn't seem to work like that.

Again, my point is to use Angular in a non-Angular project.

Any suggestion would be welcome.

5
  • 1
    Are you using angular or angularjs ? You have tagged both and it can only be one. Commented Nov 8, 2018 at 21:17
  • I am considering Angular(2). Angularjs would be an option as well. Although, I am trying to plug Angular(2). But good point, my bad for putting both tags Commented Nov 8, 2018 at 21:26
  • 1
    Angular > Angularjs in my opinion. You can even mod your T4 template to generate you .ts classes which is really handy. Can't do anything like that with angularjs Commented Nov 8, 2018 at 21:29
  • 1
    Due to the architecture of Angular being a SPA, if you want to use Razor you are out of luck. The entire front end is brought down in a bundle the first time you hit the server and then the only communication it has with the server beyond that is via ajax calls; Even navigation is trapped in the SPA without requiring the server to process the request. Apparently there is a server side option for Angular, however i've personally not heard great reviews and have not used it myself. Hope this helps. Commented Nov 8, 2018 at 21:37
  • 1
    @Zze That's the case. It's the other way round - render an Angular 'portion' inside an existing razor view. Like what we can do with a simple <script>what_ever</script> But I now what you mean. Thank you for taking he time Commented Nov 8, 2018 at 21:45

1 Answer 1

2

Check this post on how to compile Angular Elements into a web component to use it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.