AngularJS with asp.net webforms or MVC? - angularjs

We have an asp.net website running in our company. This website majorly use AJAX calls to interact with server and for that we have web methods in our code behind files.
Company is thinking to switch technology to Angular JS. I just want to know whether it is a good practice to use Angular JS with asp.net webforms or we have to convert from webforms to
asp.net MVC in order to switch to Angular JS? I have already read relevant questions but I need more specific answers, any one please put a light on this.

As I look at it, it doesn't really matter what you use, because angularjs is implemented using only javascript and html code, and in both cases I don't think that implementing it in either asp or mvc will have any major impact, this does depend on your project size and complexity but for the most part I don't think you will face any problems.Then again this is just my viewpoint on this matter.

Related

RESTFUL App in symfony 3

I am still quite confused about REST API, Angular and so on.
I would like to build simple web app which allows users to book events and I would like to do it in Symfony 3 + Angular.
In future, I could make it work on mobile phones as well.
The reason I want to do it is to learn symphony 3, REST API and Angular better and to increase chance I will get hired.
I have few questions:
1) Apart of the fact I am going to learn Angular what is the real benefit of using Angular rather than twig templates and HTML for the front end ?
2) As far I have seen people usually suggesting light weight frameworks to build REST API. Why would not they suggest symphony ?
3) What would you suggest to build to show you have got good skill set to get hired ?
1) Angular a complete framework. In your case, you would use angular as front end. This would be two options.
First one is completely using Angular, Symfony serves the RESTful API. Then twig is not involved anymore.
The other is used Angular within twig, acting like a server side rendering Angular. This way is not very common right now, rather less examples could be found.
In any case, Angular could provide single-page application, which could give your users better user experience, faster load speed, move the html view part completely to browser(make server less tasks regarding rendering the view). You could also achieve this by using twig+javascript, but it would be a bit more complex depends on your skills.
But in my opinion, the best benefits would be separate the frontend and backend from architecture perspective.
2) Symfony is a very complete PHP framework. Building a REST API is only an example of using Symfony. And in this way, some features from Symfony could not be used. I would say some lightweight framework would deliver the same result as using Symfony. It would also be easier using some lightweight framework(less code, less configuration, etc.). However, the performance of Symfony and large community might also need to take into consideration when you choose the right framework.
3) Always a good protfolio by showing your experience and skills.

SPA behaviour for an existing Play Framework webapp

We have a complex webapp built in Play Framework (1.*) and we want to move towards a SPA behaviour for it. What JS framework would you recommend for this? Most of the business logic is on the server side (Play controllers).
What would be the pros or cons of using AngularJS or ReactJS, or maybe other framework. How easy would be the integration?
Take a look at the act framework at http://actframework.org/, an ex play one that decided to take action, his video for a Rest Service is very impressive: https://www.youtube.com/watch?v=B2RRSzYeo8c
From my experience , I can recommend the following :
Indeed, You will have two applications :
SPA application : Based on reactjs framework with redux .
API application : You can any of the famous framework grails , express, laravel , ruby-on-rails ...etc.
I don't recommend to use Angular, ReactJS is more powerful for many reasons : namely virtual-dom
You can use still Play 1.x as back-end, by converting controllers methods into web-socket events or more simple REST (checkout jersey module, also for inspiration).
After you can make interacting UI HTML SPA based use ReactJS or VueJS (I prefer the second, better separation concerns and better performances).

what are the advantages of using 2 MVC architectures(frontend and backend) in same project. AngularJS and Spring MVC

what are the advantages of using 2 MVC architectures(frontend and backend) in same project. AngularJS and Spring MVC.
Without using AngularJs, can I update single div data without loading the entire page? Is AngularJS responsible for updating single <div> data out of multiple <div>s without loading entire page? If so, please explain in detail.
Once you have a single-page application you have to make sure all the different parts of that application are consistent, that's what the MVC/MV-Whatever in the front end is doing for you. That's not an issue in an old-school web application because the relevant state is regenerated with each request, but once the updates are coming in bits and pieces then different pieces of the front end need to be coming from the same model and that model needs to get updated consistently.
Obviously you can implement div updates with raw JavaScript, you don't need frameworks just to do AJAX. The JavaScript frameworks are written in JavaScript, after all. The frameworks and libraries do make things easier by doing things like papering over browser inconsistencies and providing convenient and useful features (like databinding in Angular).
The server-side MVC does become less complex and involved than it was in the old-school web application, you have less POST-Redirect-GET going on, the front end is more in control about what it is asking for. The front-end application is decoupled much more from the server-side because that whole server-side view layer of JSPs or Facelets or whatever is greatly reduced or just missing, instead you have services supplying JSON over HTTP and there is a much more limited, well-defined contract.
You can update a single element of your page without using AngularJS. As an alternative, for example, you can use JQuery.
You should wonder for the best approach for your project. This answer explains very well the differences between this two approaches.
As an aside note, AngularJS is not exactly a MVC architecture. Instead, the community has decided to call it MVW (Model View Whatever). Check this source for more details.

ASP.NET MVC and Angularjs vs ASP.NET MVC and Reactjs

I have used AngularJs on top of my ASP.NET mvc projects. Even though both AngularJs and ASP.NET are based on mvc architecture I can see some advantages when using AngularJs on top of my ASP.NET mvc projects. The main advantage that I see in this approach is better rendering of views. If so why not use ReactJs with ASP.NET mvc since it is purely focusing on views. Why do we have to mess up with two mvc frameworks. Won't it be better to use Reactjs on top of ASP.NET mvc than using AngularJs and ASP.NET mvc combination (Note that I will always use ASP.NET mvc and I don't want to use a pure JavaScript framework). Please correct me if I am wrong. Thanks in advance.
I've used both angular and react in projects in the past. With angular you dirty your html markup with angular code. With react it's all encapsulated in a component. As I was never an expert with angular I may not have used it to the best of it's ability but to me Reactjs seems like the better framework and seems like a better fit with ASP.NET MVC.
I don't believe there is one correct tool to do the job though. It's really whatever suits your needs and what your comfortable with. I would suggest giving Reactjs a shot though.

AngularJS vs multiple forms in ASP.NET MVC

I'm building a complex job application. And I want it to be a SPA. I'm using AngularJS with Asp.net MVC (not web API). Everything is working so far, but I realized that I can no longer take advantage of a lot of features that ASP.NET MVC provides. So far I know I have to write my own code for these features:
all validation have to be on client side. I can't reuse some attributes I wrote in C#.
[ValidateAntiForgeryToken] attribute no longer work.
I can't use classes that generated by entity framework directly. It will give "circular reference" error for that.
I almost regret to take this approach. It's nice to have 2-way binding, but I have to write a lot of extra code that I could have avoided if I don't use angularJS. I can write multiple forms in one page and achieve the same result like shown here:
Multiple Forms in same page ASP.net MVC.
Can you tell what other MVC features I still have to write code for? when should I use angularJS and when should I use ASP.NET multiple forms on the same page?
Thanks
You can ease the pain of those listed points, but still, it might be better to decide what's better for you from the beginning - rendering views client-side (angular) or server-side (mvc).
Anyways, there are known solutions for some of the listed issues. Angular directive for MVC validation attributes:
https://github.com/alisabzevari/ngval
For the [ValidationAntiForgeryToken] here is also a solution: https://julianjelfs.wordpress.com/category/mvc/
I have not understood the thing regarding multiple forms (I believe it's unrelated to angular), so skipped on this..

Resources