Wednesday, January 8, 2014

a simple AngularJS example showing off a controller and a filter

Note the $scope variable in the controllers' function signature:

<!DOCTYPE html>
<html ng-app>
   <head>
      <script src='https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.min.js'>
      </script>
      <script>
         function foo($scope) {
            $scope.bar = new Date();
         }
      </script>
   </head>
   <body>
      <div ng-controller='foo'>
         The time is: {{bar|date:'h:mm:ss a'}}
      </div>
   </body>
</html>

No comments:

Post a Comment