Hi there, I'm new to Angular and I'm running into an issue where I can't redirect to the signup.html page when I hit localhost:port/projectname/
Even though I have specified the template URL for signup in app.js, I keep getting a 404 error.
However, when I try hitting localhost:port/projectname/signup.html directly, the file opens without any problems. Am I missing something here?
I really need to be able to access the signup.html page when visiting localhost:port/projectname/
Here's the relevant code from app.js:
var app = angular.module('pollApp', ['ngRoute']);
app.config(['$routeProvider',function($routeProvider){
$routeProvider
.when('/Welcome', {
templateUrl: '/Welcome.html',
controller: 'submitCtrl'
})
.when('/', {
templateUrl: '/signup.html',
controller: 'submitCtrl'
})
.otherwise({
redirectTo: '/Welcome.html'
});
}]);
And below is submitController.js:
app.controller('submitCtrl',['$scope', '$http', '$location',
function ($scope, $http, $location) {
$scope.timeZones = [
{ label: '(GMT-09:00) Alaska', value: 'Alaska' },
{ label: '(GMT-08:00) Pacific Time (US & Canada)', value: 'Pacific Time (US & Canada)' }
];
$scope.submit=function() {
var userDetails=new Object();
userDetails.firstname=$scope.firstname;
userDetails.lastname=$scope.lastname;
userDetails.Companyname=$scope.Companyname;
userDetails.Email=$scope.Email;
userDetails.timezone=$scope.timezone;
console.log(userDetails);
$http({
method: 'POST',
data: userDetails,
url:'/mongopractise/rest/signup/userdata',
headers: {'Content-Type':'application/json'}
}).success(function(data, status, headers, config) {
console.log("success data"+JSON.stringify(data));
$scope.username=data;
$location.url('/Welcome.html').replace();;
}).
error(function(data, status, headers, config) {
console.log("Failure data"+data);
});
}
}]);
Lastly, this is part of the content from Signup.html:
// The HTML content for the signup form goes here...