Tutorial 3 - $sope in controller

Tutorial 3 - $sope in controller
$scope is an object data storage bridge, or we can understand it as a data warehouse which other objects as Controller, Service will use and exchange of information through it.

How to define a $scope in Javascript?



 <script>  
   
 myWebApp = angular.module('myWebApp', []);  
   
 myWebApp.controller("Controller01", function($scope){   
  $scope.message = 'Welcome to UI-Tutorials blog';});  
   
 myWebApp.controller("Controller02", function($scope){   
 $scope.message = 'UI-Tutorials share basic UI tutorials';});  
   
 </script>  

How to use it in HTML?
 <body ng-app="myWebApp">    
 <div ng-controller="Controller01">    {{message}}  </div>    
 <div ng-controller="Controller02">    {{message}}  </div>  
 </body>  


No comments:

Post a Comment

Popular Posts