Simple pages with controller



examples/angular/simple_pages_controller.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport"
     content="width=device-width, initial-scale=1, user-scalable=yes">
  <script src="../angular/angular.min.js"></script>
  <script src="simple_pages_controller.js"></script>
  <title>Simple Pages</title>
</head>
<body ng-app="DemoApp" ng-controller="DemoController">
<div>
  <div>
      <button ng-click="goto('first')">First</button>
      <button ng-click="goto('second')">Second</button>
  </div>
  
  <div ng-show="page === 'first'">
  <h2>First</h2>
  </div>
  
  <div ng-show="page === 'second'">
  <h2>Second</h2>
  </div>
 
</div>

</div>
</body>
</html>

examples/angular/simple_pages_controller.js
angular.module('DemoApp', [])
.controller('DemoController', ['$scope', function($scope) {

    $scope.page='first';

    $scope.goto = function(name) {
        console.log("Switching from " + $scope.page + " to " + name);
        $scope.page = name;
    }
}]);