Simple AngularJS Example
HTML
<a href=#/>Page One</a> | <a href=#/b>Page Two</a>
<div ng-view></div>
JavaScript
var app = angular.module("app", []);
app.config(function($routeProvider) {
with($routeProvider) {
//An alternative is using templateUrl: 'path/to/template.html'
when("/", {template:"<p>{{message}}</p>", controller:ACtrl});
when("/b", {template:"<p>{{message}}</p>", controller:BCtrl});
otherwise({redirectTo:"/"});
}
});
function ACtrl($scope) {
$scope.message = "Hello from page one";
}
function BCtrl($scope) {
$scope.message = "Hello from page two";
}