Hi i am newbie to Angular Js. i am doing sample application (SPA). This is directory structure.
http://localhost:8080/
demoApp
---- index.html
---views
----add.html
----list.html
----edit.html
----view.html
---js
demoapp.js
let me paste necessary code below...
dempapp.js
var demoApp = angular.module("demoApplication", ["ngRoute"]);
demoApp.config(["$routeProvider","$locationProvider",function ($routeProvider,$locationProvider) {
$routeProvider.when('/list', {
templateUrl: 'views/list.html',
controller: 'ListController'
}).when("/add",{
tempalteUrl : 'views/add.html',
controller:'addController'
}).when("/edit",{
tempalteUrl : 'views/edit.html',
controller:'addController'
}).when("/view",{
tempalteUrl : 'views/view.html',
controller:'addController'
}).otherwise({
redirectTo: '/list'
});
}]);
index.html
<html data-ng-app="demoApplication">
<head>
<title>Demo Application</title>
<script src="./lib/angular.min.js"></script>
<script src="./lib/angular.route.min.js"></script>
<script src="./js/demoapp.js"></script>
</head>
<body>
<data-ng-view></data-ng-view>
</body>
</html>
list.html
<div ng-controller="ListController">
<table>
<thead>
<tr>
<td>Serial Number</td>
<td>User Id</td>
<td>First Name</td>
<td>Last Name</td>
<td> Add User</td>
<td> view User</td>
<td> Edit User</td>
<td> Delete User</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in users">
<td>{{$index+1}}</td>
<td>{{user.id}}</td>
<td>{{user.firstName}}</td>
<td>{{user.lastName}}</td>
<td><div style="float:left;"><a href="#/add">Add User</a></div></td>
<td><div style="float:left;"><a href="#/view" id="viewUser">View User</a></button></button></div></td>
<td><div style="float:left;"><a href="#/edit" id="editUser">Edit User</a></div></td>
<td><div style="float:left;"><a href="#/delete" id="deleteUser">Delete User</a></div></td>
</tr>
</tbody>
</table>
</div>
The Issue is, when clicking Add or edit or view from the navigation url getting changed but Template not displaying. please help me out what i am doing wrong here...
ng-controller="ListController"in the html as you have already specified in routeprovider. Also check for any 404 from server.http://localhost:8080/#/index.html/listworks.