AngularJS Tutorial - Get data from scope








The following code shows how to Get data from scope.

Example


<!DOCTYPE html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--   w  w w  . jav  a  2  s  . com-->

<body ng-app="myApp">
  <div ng-controller="MyCtrl">
  Hello, {{myName}}!
  </div>
<script type='text/javascript'>
    var myApp = angular.module('myApp',[]);
    function MyCtrl($scope) {
        $scope.myName = 'Hi';
    }
</script>
</body>
</html>

The code above is rendered as follows: