Reputation: 317
I have a problem with Web Application, I try to do when a user enter on /#/home to display a text.
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular-route.js"></script>
<script>
var app = angular.module('cacat', ['ngRoute']);
app.config(function($routeProvider, $locationProvider) {
$routeProvider.
when('/home', {
template: 'DADA'
}).
otherwise({
redirectTo: '/'
});
if (window.history && window.history.pushState) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
}
});
</script>
</head>
<body ng-app="cacat">
</body>
I tried 127.0.0.1/#/home, 127.0.0.1/home and both doesn't work.
Upvotes: 0
Views: 53
Reputation: 4488
Sorry for the delay I havent been home and dont really have apache here to try it out but this works perfectly fine
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular-route.js"></script>
<script>
var app = angular.module('cacat', ['ngRoute']);
app.config(function($routeProvider, $locationProvider) {
$routeProvider.
when('/home', {
template: 'DADA'
}).
when('/',{
template:"<a href='index.html#/home'> Go Home</a>"
} ).
otherwise({
redirectTo: '/'
});
/* if (window.history && window.history.pushState) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});*/
});
</script>
</head>
<body ng-app="cacat">
<ng-view></ng-view>
</body>
I comment out the history part because i need apache to try that. but you were just missing the ng-view tag basically
Hope it helps
Upvotes: 1