My index.html has a ui-view where I display greeting.html, and greeting.html has a ui-view where I am trying to display greeting.planet.html:
greeting.planet.html:
<div>world!</div>
greeting.html:
<div>Hello</div>
<div ui-view></div> #NESTED VIEW HERE************
index.html:
<!DOCTYPE html>
<html ng-app="myapp"> #APP DIRECTIVE HERE************
<head>
<title>Test</title>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<link href="app.css" rel="stylesheet">
</head>
<body ng-controller="MainCtrl"> #MainCtrl CONTROLLER HERE*********
<div class="container">
<div class="jumbotron text-center">
<h1>Test App</h1>
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div ui-view></div> #NESTED VIEW HERE**********
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.11/angular-ui-router.js"></script>
<script src="app.js"></script>
</body>
</html>
When I navigate to http://localhost:4444/index.html
, the following code succeeds in displaying the nested views:
app.js:
var app = angular.module("myapp", ['ui.router']);
app.config([
'$urlRouterProvider',
'$stateProvider',
function($urlRouterProvider, $stateProvider) {
$urlRouterProvider.otherwise('greeting');
$stateProvider
.state('greeting', {
//url: '/greeting',
templateUrl: 'greeting.html'
})
.state('greeting.planet', {
//url: '/planet',
templateUrl: 'greeting.planet.html'
});
}]);
app.controller('MainCtrl', ['$state', function($state) {
$state.transitionTo('greeting.planet');
}]);
But if I uncomment the url keys in the states, then greeting.planet.html doesn't display. Why?