I'm currently facing an issue with my setup. I have a local angular front-end running on localhost using an Apache Server on Linux. When I try to access localhost, everything works fine and I can see my index.html. However, I have a link in the index.html that should redirect users to localhost/users. Unfortunately, I'm having trouble getting this to work despite trying various solutions from Stack Overflow. Can anyone spot what I might be doing wrong?
Here's my app.js:
(function() {
var app = angular.module('linkrec', ['ngRoute']);
app.config(function($routeProvider, $locationProvider) {
$locationProvider.html5mode(true).hashPrefix('!');
$routeProvider
.when('/users', {
templateUrl: '/users.html',
});
});
app.controller('UsersController', [ '$http', function($http) {
var linkrec = this;
linkrec.users = [];
$http.get('https://localhost:9443/users').success(function(data){
linkrec.users = data;
});
} ]);
Here's my index.html:
<!DOCTYPE <!DOCTYPE html>
<html ng-app="linkrec">
<head>
<title>LinkRec</title>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="linkrec.css">
</head>
<body>
<script type="text/javascript" src="node_modules/angular/angular.js"></script>
<script type="text/javascript" src="node_modules/angular/angular-route.js"></script>
<script type="text/javascript" src="app.js"></script>
<h1>LinkRec</h1>
<div class="container" ng-view>
<a href="/users"><h2>Users</h2></a>
<h2>Vacancies</h2>
<h2>Groups</h2>
</div>
</body>
</html>
This is how my .htaccess used to look like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) /index.html/#!/$1
</IfModule>
And here's how it looks now:
# Apache .htaccess
# angularjs pushstate (history) support:
# See http://www.josscrowcroft.com/2012/code/htaccess-for-html5-history-pushstate-url/
FallbackResource /index.html
If anyone notices what I might be missing or doing wrong, please let me know. All the necessary Angular files are present and linked correctly. Thank you for your help.