Reputation: 365
I've got a simple angular.js app with two views: /login & /register. My index.html looks this way:
...
<body>
<ul class="menu">
<li><a href="#/login">Login</a></li>
<li><a href="#/register">Register</a></li>
</ul>
<div ng-view></div>
...(javascript inclusions)...
app.js
var adventureApp = angular.module('ownAdventure', [
'ngRoute',
'ngCookies',
'Login',
'Register'
]);
adventureApp.config(['$routeProvider', '$locationProvider',
function ($routeProvider){
$routeProvider
.when('/login', {
controller: 'LoginController',
templateUrl: '/login/login.view.html'
})
.when('/register', {
controller: 'RegisterController',
templateUrl: '/register/register.view.html'
})
.otherwise({ redirectTo: '/login' });
}]);
I've got both Login and Register modules in sepparate .js files, and added the LoginController and RegisterController accordingly in both files exactly the same.
login.controller.js (same with register):
'use strict';
var loginController = angular.module('Login', ['ngRoute', 'ngCookies']);
loginController.controller('LoginController', ['$scope',
function($scope) {
$scope.test = 'This is a simple test';
}]);
Both login/ and register/ folders are inside the app/ folder at the same level as app.js, therefore I cannot figure out why I constantly get the following error message: GET http://localhost:8000/login/login.view.html 404 (Not Found)
Thank you in advance.
Upvotes: 0
Views: 4665
Reputation: 684
"The error message : GET http://localhost:8000/login/login.view.html 404 (Not Found)" Implies that there is no login.view.html in the given folder hierarchy or it is not accessible at the given moment. As this error is related to your code, we will not bother about it. Coming to the folder hierarchy, what is your application name? (I believe it is "ownAdventure"). So the index.html page loads at "localhost:8080/ownAdventure/". You mentioned "Both login/ and register/ folders are inside the app/ folder at the same level as app.js" it doesn't help much, because you didn't mention the folder hierarchy for app.js. I assume that app.js is right under your app folder.
In that case "localhost:8080/ownAdventure/login/login.view.html" will be accessible.
Note: "templateUrl: '/login/login.view.html'" the path provided here is relative to the parent path, not to the file from which it is called(in this case app.js).
Upvotes: 2