I am currently in the process of implementing ngRoute into my application, but I am facing challenges with getting it to function properly.
To showcase my efforts, I have developed a basic app.
index.html:
<!DOCTYPE html>
<html ng-app="tester">
<head>
<meta charset="utf-8" />
<title>ngRoute Integration Test</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.0/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.0/angular-route.js"></script>
<script src="app.js"></script>
</head>
<p>Click on this link to change views:</p>
<a href="/tests">Test View</a>
<div ng-view></div>
</html>
app.js
var app = angular.module('tester', ['ngRoute']).config(function($routeProvider) {
$routeProvider
.when('/tests', {
templateUrl: 'tests.html',
controller: 'TestCtrl'
});
});
app.controller('TestCtrl', ['$scope', function($scope){
$scope.title = "This is a Test Page";
}]);
tests.html
<p>{{ title }}</p>
You can view my attempt here: http://plnkr.co/edit/ntgV5xFTl46tBugEnCVe?p=preview. Any assistance with resolving this issue would be greatly appreciated!