Basic definitions of AngularJS

A JavaScript framework (Not a library) based on MVV pattern created by Google which makes the code readable, organized and extensible.  You know in large application developments specially in SPAs which has been on top during the last few years, managing and developing JavaScript in client side is so hard. AngularJS provides some powerful features for developers like  Expressions, Directives, Data Binding, Filters, Partial Views, Modules, Dependency Injection, Routes, Controllers, Scope, Services… and makes the JavaScript development more easier and powerful.

 Based on Wikipedia, AngularJS directives allow the developer to specify custom and reusable HTML tags that moderate the behavior of certain elements.

  1. ng-app: Declares an element as a root element of the application allowing behavior to be modified through custom HTML tags.
  2. ng-bind: Automatically changes the text of an HTML element to the value of a given expression.
  3. ng-model: Similar to ng-bind, but allows two-way data binding between the view and the scope.
  4. ng-class: Allows class attributes to be dynamically loaded.
  5. ng-controller: Specifies a JavaScript controller class that evaluates HTML expressions.
  6. ng-repeat: Instantiate an element once per item from a collection.
  7. ng-show & ng-hide: Conditionally show or hide an element, depending on the value of a boolean expression. Show and hide is achieved by setting the CSS display style.
  8. ng-switch: Conditionally instantiate one template from a set of choices, depending on the value of a selection expression.
  9. ng-view: The base directive responsible for handling routes that resolve JSON before rendering templates driven by specified controllers.
  10. ng-if: Basic if statement directive which allow to show the following element if the conditions are true. When the condition is false, the element is removed from the DOM. When true, a clone of the compiled element is re-inserted. 

 

AngularJS features are not come in a single blog post (I'll cover all of them in the future). but for instance run this piece of code and see the result (This is again one of those hello world samples!)

  1. <html>
  2. <head>
  3.     <title>Angular</title>
  4.     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
  5. </head>
  6. <body>
  7.     <div> <input type="text" ng-model="SayHello"> <h1>, {{ SayHello}}!</h1> </div>
  8. </body>
  9. </html>

 


Tags: JS Libraries


comments powered by Disqus