Monday, 1 September 2014

AngularJS Module and Controller Simple example

<!DOCTYPE html>
<html>
<head>
<script
       src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
</head>

<body>

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

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

</body>
</html>

 ________________________________________________________________________

ng-app="myApp" : here in double quote we i have written application name

ng-controller : view controller name to visible scope data in to it

$scope : bridge between data and controller

[] : dependency module name array 


1 comment:

  1. Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.We are providing AngularJs training in velachery.
    For more details: AngularJs training in velachery

    ReplyDelete