0

I am following a basic tutorial to learn Angular Js here

To cut in short i am creating a main page(index.html) and another page(login.html). I wrote the basic html but for instance i`ll share the important lines that effects Angular.

app.js

var app = angular.module("app", []).config(function($routeProvider){ $routeProvider.when('/login', { templateUrl: 'login.html', controller: 'LoginController' }); $routeProvider.otherwise({redirectTo : '/login'}); }); app.controller('LoginController', function(){ // To be left blank at the moment. }); 

Login.html

<div id="login" class="row"> <div class="large-3 large-offset-3"> <form> <fieldset class="radius"> <div class="row"> <div class="large-6 columns"> <input type="text" name="username" placeholder="username"> </div> <div class="large-6 columns"> <input type="password" name="username" placeholder="password"> </div> </div> <div class="row"> <div class="large-12 columns"> <button type="submit" class="button large expand radius">Log In</button> </div> </div> </fieldset> </form> </div> 

index.html

<div class="row"> <div class="large-12"> <h1> Introduction to Angular Js</h1> <div id="view" ng-view></div> </div> </div> 

Note: When i try to open localhost/angular it shows me index.html and when i try doing localhost/angular/login it says "404 Not Found"

2 Answers 2

1

Try accessing the url: localhost/angular/#/login

Sign up to request clarification or add additional context in comments.

3 Comments

It is redirecting me back to localhost/angular which is because of .otherwise may be ... but it is now even showing the view for login.html which it should being a one page app no?
do you have an htaccess ? try to join Try accessing the url: localhost/angular#/login
as i said it is redirecting me to main page again ... may be because of $routeProvider.otherwise()
-1

add the file angular.route.js and this in your module

var app = angular.module("app", ['ngRoute']) 

and don't forget it, it can be useful

$routeProvider.otherwise({ redirectTo: '/' });

3 Comments

I am still getting the same problem.
you do not have route define for /
I added angular-route.js. Now let me tell you the hierarchy. I have index.html and login.html. when i open localhost/angular - it shows me index.html now i want to show login.html when i open localhost/angular/login I dont know what wrong i am doing.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.