I have began learning AngularJS and decided to go with Angular-UI-Router for all of my routing needs, but unfortunately, I am unable to get the templateURL property of the $stateProvider to render. I have followed tutorials to the world's end, and cannot get templateURL to work (even when following the tutorial). Am I missing something?
All of the following documents are located within the same directory. I am opening the webpage directly in Chrome (I am not combining with node/express or any other service).
index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.10/angular-ui-router.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body ng-app="app">
<nav>
<a ui-sref="home">Home</a>
<a ui-sref="about">About</a>
</nav>
<div ui-view></div>
</body>
</html>
app.js
var app = angular.module('app', ['ui.router']).
config(['$stateProvider', '$urlRouterProvider',
function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
.state('home', {url: '/home', template: '<h1>HOME</h1>'})
.state('about', {url: '/about', templateURL: 'about.html'});
}]);
about.html
<div><p>About</p></div>
templateUrl
(case sensitive) – Phil Sep 2 '14 at 1:45file://
protocol. Angular will try to fetch the template viahttp://
and that won't work due to browser security settings. Try setting up a webserver. – ivarni Sep 2 '14 at 4:56