Pages

Thursday 8 October 2015

Basics of AngularJs



Why AngularJs?
There are various frameworks out there which helps us with web application development. Then why AngularJs? Here are some of the core features of AngularJs.

MVC Architecture
       AngularJs applications are built using  MVC (model–view–controller) Or MVVM (model–view–viewmodel) architecture. This ensures clear isolation between application components.

MVC is an architectural pattern which modularise business logic,presentation logic and interaction between the two. Here Model is the data (like any data object) View is presentation layer (HTML,or partial views) and Controller is a function which apply business logic and present it to view. Spring MVC is a widely used server side architecture.

The architecture followed in angularJs slight different than the conventional MVC frameworks. Here controller acts as bridge between view and model. So It is also called as MVVM (model–view–viewmodel) framework. To avoid such confusion and arguments a more common usage evolved is MVW ( Model View Whatever).

Use of more familiar HTML
  HTML is the template language in angularJs. Most of the web developers are familiar with HTML tags. AngularJs just extend the features of html using it's directives.(We will see directives in details later).

Easy Integration
AngularJs can be easily integrated to web applications by simply importing AngularJs library.
This can be done in two ways
1. Download the angular.js lib from https://angularjs.org/ and keep it in local application directory.

2. Point your code directly to angular script on the Google CDN server.

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>

SPA design
  In a Single Page Application (SPA) all necessary code (HTML, CSS and JavaScript) is retrieved with a single page load. Appropriate resources are dynamically loaded and added to the page as necessary. This reduce much loading time and pages become more responsive.
AngularJs has different directives to support SPA design.

Two way data-binding
This is one of the very important feature of AngularJs. This provides synchronisation between Model and View layers. Model changes propagated to the View, and View changes are instantly reflected back in the Model. Below is the code which explains this can be implemented using plain JavaScript and AngularJs.

Problem scenario: We have an input textbox and a model object. Model object hold the value in the textbox. At any point of time these two should be in sync.

Example using javascript function
<script>
     var modelObject="";
     function syncToModel() {
      modelObject = $("#inputtextbox").val();
     }
     function syncToView(){
      $("#inputtextbox").val(modelObject);
     }
     //Assume some other function which modifies the modelObject value.
     function updateModeldata(){
      modelObject ="New value";
      //To reflect the latest value to HTML textbox call syncToView function
      syncToView();
     }
</script>
<input type=text id="inputtextbox" onchange="syncToModel()"/>
 
Using AngularJs
<input type=text id="inputtextbox" ng-model="modelObject"/>

You've just seen one of the very powerful and frequently used directive of angularJs ng-model. This does the same thing as javascript functions syncToModel and syncToView but with the essence of much reduced coding.

So that's all about the basics of AngularJs.Now create your first application - Simple AngularJs Application in eclipse.

46 comments:

  1. Come and read us!! We are moving our blog into a new site with a much more pretentious goal. We are going to teach how to be AngularJS Ninjas!!! That's right! We have taken a couple of weeks to prepare our free workshop, absolutely free!!!!


    AngularJS Certification Training in Chennai

    ReplyDelete
  2. The information you provide in this blog is very nice. you provide some technical points that help me to learn angularjs.Want to learn Angularjs online Training for free.


    Angularjs Online Training

    ReplyDelete
  3. It was really a nice article and i was really impressed by reading this AngularJS5 Online Training Bangalore

    ReplyDelete
  4. Thank you for benefiting from time to focus on this kind of, I feel firmly about it and also really like comprehending far more with this particular subject matter. In case doable, when you get know-how, is it possible to thoughts modernizing your site together with far more details? It’s extremely useful to me 
    Python training in usa
    Python training in marathahalli
    Python training in pune

    ReplyDelete
  5. Excellant post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.

    Devops training in sholinganallur

    ReplyDelete
  6. That was a great message in my carrier, and It's wonderful commands like mind relaxes with understand words of knowledge by information's.
    Blueprism training in marathahalli

    Blueprism training in btm

    Blueprism online training

    ReplyDelete
  7. Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.

    AWS Interview Questions And Answers

    AWS Training in Bangalore | Amazon Web Services Training in Bangalore

    Amazon Web Services Training in Pune | Best AWS Training in Pune

    ReplyDelete
  8. You are doing a great job. I would like to appreciate your work for good accuracy
    Data Scientist Course in Chennai

    ReplyDelete
  9. Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.

    6 of 19BacklinksInboxxBalaji hope tutors AttachmentsMay 29, 2019, 3:33 PM (5 days ago)to me

    --
    M Balaji
    Digital Marketing Analyst
    Marketing
    HopeTutorsm:7871012233
    a:18, HARITHA BUILDING FIRST FLOOR, JANAKPURI FIRST STREET, VELACHERY, Chennai, Tamilnaduw:www.hopetutors.com e: balaji.hopetutors@gmail.com
    Contact Us

    2 AttachmentsPreview attachment Links.txt [Text] Preview attachment Magi.xlsx [Excel] Thanks a lot.Received, thank you.Thanks, I'll check them out. AWS Training in Chennai
    Blue Prism Training in Chennai
    Angular JS Training in Chennai
    Uipath Training in Chennai

    ReplyDelete
  10. Excellent Blog, I have read all your blogs. Thanks for sharing important information. Such a nice postweb design company in velachery

    ReplyDelete
  11. Informative post indeed, I’ve being in and out reading posts regularly and I see alot of engaging people sharing things and majority of the shared information is very valuable and so, here’s my fine read.
    click here animation
    click here accessibility
    click here arrow gif
    click here app
    click here animation css

    ReplyDelete
  12. Great article ...Thanks for your great information. AngularJS Training in Pune

    ReplyDelete
  13. Excellent Blog! I would like to thank for the efforts you have made in writing this post. Thanks for sharing. Great website
    Angular JS Online training
    Angular JS training in Hyderabad

    ReplyDelete
  14. Nice Post! Thank you for sharing very good post, it was so Nice to read and useful to improve my knowledge as updated one, keep blogging.
    AWS training in chennai | AWS training in anna nagar | AWS training in omr | AWS training in porur | AWS training in tambaram | AWS training in velachery

    ReplyDelete
  15. Have you been thinking about the power sources and the tiles whom use blocks I wanted to thank you for this great read!! I definitely enjoyed every little bit of it and I have you bookmarked to check out the new stuff you post thnanska
    Ai & Artificial Intelligence Course in Chennai
    PHP Training in Chennai
    Ethical Hacking Course in Chennai Blue Prism Training in Chennai
    UiPath Training in Chennai

    ReplyDelete
  16. Thank you for sharing the post,it is very helpful to those who are looking for it.
    Full Stack Online Training

    ReplyDelete
  17. keep up the good work. this is an Assam post. this to helpful, i have reading here all post. i am impressed.Thank you!!
    Nice information thanks for sharing it’s very useful. This article gives me so much information.

    Data Science Training In Chennai

    Data Science Online Training In Chennai

    Data Science Training In Bangalore

    Data Science Training In Hyderabad

    Data Science Training In Coimbatore

    Data Science Training

    Data Science Online Training

    ReplyDelete
  18. Thank you, for providing this informative and comprehensive blog. This is a very interesting Blog.

    Rummy Game App Development

    ReplyDelete
  19. Nice information. It is very useful for me to learn and understand easily. Thanks for sharing
    angularjs online training in hyderabad

    ReplyDelete
  20. Interesting blog. It would be great if you can provide more details about it. Thanks you
    Angular Experts in India

    ReplyDelete
  21. I am really happy to say it’s an interesting post to read. I learn new information from your article, you are doing a great job. Keep it up

    Rummy game development company

    ReplyDelete
  22. This comment has been removed by the author.

    ReplyDelete
  23. Hire Angular JS Developers from well-famous Software, web, and app development companies, and save your hiring process based on different hiring models. Agnito Technologies is a leading software, web , and mobile app development company that offers to hire dedicated angular developers remotely for full-time, part-time, and an hourly basis as per your project requirements. If you are looking to get customized web apps to improve your web design architecture by using Angular js technologies then choose our expert team of Angularjs developers at a very low price.

    Hire Angular App Developers

    ReplyDelete
  24. Very interesting & informative blog published by you. I really appreciate your hard work in giving us valuable information.

    Software Product Development Services

    ReplyDelete