ng-MAGIC

Quick Recap

  • $scope 
  • Modules and Controllers
  • Dependency Injection
  • Directives
  • Filters

$scope

  • Glue between view and controller
  • Root scope: Accessible for every controller and Module
  • Scope: Accessible to this controller
  • Scope provides following API
    1. $watch
    2. $apply

$scope

Modules and Controllers

  • Module defines an application
  • Controllers are used to perform scope manipulations
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="myCtrl">
{{ firstName + " " + lastName }}
</div>

<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
    $scope.firstName = "John";
    $scope.lastName = "Doe";
});
</script>

</body>
</html>

Dependency Injection

Dependency Injection

Directives

  • Directives are extended HTML attributes with the prefix ng-
  • Compile function- Deals with HTML elements
  • Link function- Deals with scope manipulations in it
  • Transcluding
  • Isolation of scope

Built-In filters holds good

uppercase

Currency

Angular provides lot of inbuilt Filter

Its MyFilter

Text

app.filter('myFilter', function() {

  return function(input, optional1, optional2) {

    var output;

    // Do filter work here

    return output;

  }

});

Overview of Angular Beginners

By mohammad sirajuddin Rayyan

Overview of Angular Beginners

Short ppt of basic angular modules

  • 201