Disqus for hsalearn

AngularJS

AngularJS version: 1.3.0
https://angularjs.org/
https://builtwith.angularjs.org/
http://plnkr.co/

Two Requirements
  • Add a <script> tag pointing to angular.js.
    • <script scr="angular.js"></script>
  • Add an ng-app attribute in your HTML.
    • ng-app is an Angular directive.
    • The ng is short for Angular.
    • <div ng-app> This area controlled by Angular! </div>



JavaScript Patterns
  • Functions as abstractions
  • Functions to build modules
  • Functions to avoid global variables

Controller Basics

  • Controller directive in HTML (ng-controller)
  • Controller will be a function that Angular invokes
  • Controller takes a $scope parameter
  • Attach model to $scope.


Controller Capabilities

  • Multiple controllers
  • Complex object
  • Nested controllers


*Tip: When load image use ng-scr="Image src" to don't get 404 error.


$http Service

  • Encapsulates HTTP communication
    • GET, POST, PUT, DELETE
  • Can "ask" for $http inside a controller
    • Just add as another parameter to controller function
  • Always returns a promise
    • A promise to deliver a value in the future


GitHub API

  • Available from JavaScript in browser.
  • Returns JSON (easy to convert into objects)
  • No authentication or client key required.


Modules

  • Controllers usually live in modules
    • Avoids the global namespace
  • Working with modules
    • Create a module with a name
    • Register your controllers in the module
    • Tell Angular to use your module with ng-app











    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment

 
Copyright © 2013. HSA Learn - All Rights Reserved
Template Created by ThemeXpose | Published By Gooyaabi Templates