I am new to angular js. I am trying to build simple app in which if If i load through ng-route it is not able to find view1.html whereas if I load from within same index.html it works. I already went through following post with same issue in which we have inject ibrary dependency of ng-route, but still it is not working
index.html
<!DOCTYPE html>
<html ng-app="demo">
<head >
<meta charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"> </script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular-route.min.js">
</script>
</head>
<body> Test
<div ng-view=""> </div>
<script>
var demo = angular.module('demo',['ngRoute']);
demo.config(function($routeProvider) {
$routeProvider.when('/',
{
controller:'showswitch',
templateUrl: 'view1.html'
})
.otherwise({redirectTo:'/'})
});
demo.controller('showswitch', function($scope) {
$scope.phones = [
{'name': 'Nexus S',
'snippet': 'Fast just got faster with Nexus S.',
'age': 1},
{'name': 'Motorola XOOM™ with Wi-Fi',
'snippet': 'The Next, Next Generation tablet.',
'age': 2},
{'name': 'MOTOROLA XOOM™',
'snippet': 'The Next, Next Generation tablet.',
'age': 3}
];
});
</script>
</body>
</html>
(view1 and index are under same directory)
view1.html
<div>
<h1> View1 </h1>
<input ng-model="query">
<select ng-model="orderProp">
<option value="name">Alpha</option>
<option value="age">Age</option>
</select>
<ul class="phones">
<li ng-repeat="phone in phones | filter:query | orderBy:orderProp">
<span>{{phone.name}}</span>
<p>{{phone.snippet}}</p>
</li>
</ul>
</div>
in – SeriousDron Mar 16 '15 at 19:38
also. The URL in browser do turn to file:///Y:/web-app/phonesapp/index.html#/ when i loaded file:///Y:/web-app/phonesapp/index.html – Prannoy Mittal Mar 16 '15 at 19:42