This post is taken from Dhananjay Kumar.
In short, this post will touch upon:
- adding an AngularJS library in ASP.NET MVC;
- reference of AngularJS, bundling and minification;
- fetching data using the Entity Framework database;
- returning JSON data from an ASP.NET controller;
- consuming JSON data in an AngularJS service;
- using AngularJS service in AngularJS controller to pass data to the view; and
- rendering data on an AngularJS View
We build a single page app instead of a standard MVC app to avoid re-rendering pages and performance issues. Also SPAs can provide a rich, desktop-like environment. But what to choose ..?
SPA needs heavy jQuery Ajax to build frontend and mixed frontend tools like Angular JS, duplicate js models, Knockout JS to do the binding and etc… SPA looks pretty, fancy and responsive. but, it’s hard to unit test since its complicated and mixed technologies all over the place. I would suggest to use Regular MVC structure while build medium to large app, utilize area to grouping the feature of your app. you can implement good security measurement, apply strong validations to your app. your app will close to HTML easy for maintenance, light jQuery that enhances the UI is already good when you want to focus on the functions and features instead of fancy UI. Continue reading
I have started studying Angular framework a few weeks ago. I always try to keep up with frameworks out there in the world to see if any of them can save me time and fill in specific needs for my projects. I was attracted by apparent simplicity of Angular, judging by few demos I viewed. Continue reading
A directive is simply a function that we run on a DOM element to give it added functionality. In Angular, we’ll use directives everywhere. Continue reading
The basics of Angular can be broken down into 5 major components:
- Dependency Injection
It’s important to note that in the Angular, we’re not looking up elements by a selector and then directly manipulating the HTML. Instead, we’re declaring where the variables should be attached and then Angular takes care of the plumbing for us.
The angular way of developing applications dictates that we take care of the data and angular will take care of the DOM manipulation.