简体   繁体   中英

From which file does Angular js execution start?

I have a angular js project. I downloaded the seed project and made some changes. I am able to run it. When I start the server, i have to manually go to localhost:portnum/app/index.html to run the index.html"

How can i configure that when i type my localhost/portnum, it should redirect to index.html directly. I have gone through many angular projects. I am not able to understand where does the angular execution start. I mean, from where does the execution begin. There are lot many js files. Kindly help in this regard.

Sabarisri Subramaniyan

I agree that it isn't an angular issue. Your web server will make what ever directory you tell it to the root of your website/app. One really simple way you could handle this (this is what I do when testing on localhost):

if you have python installed use the python simple http server:

first change into your app directory:

cd /app

then run the python simple http server from inside of that directory:

python -m SimpleHTTPServer 8080

the server is smart enough to know that index.html is the first page it should load, so all you have to do now is go to your browser and type:

http://localhost:8080

done.

There are other web servers that will accomplish this same thing. the important thing to remember is that it will look inside whatever folder you designate as the root folder. By launching the python simple server while inside of the /app folder, that folder will be set as the root. Most web servers will know that index.html is the first page of the site just from the common use of "index".

Good luck!

Use Routes like below

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

// configure our routes
app.config(function($routeProvider) {
    $routeProvider

        // route for the home/default page
        .when('/', {
            templateUrl : 'pages/home.html',
            controller  : 'homeController'
        })
        .when('/page1', {
            templateUrl : 'pages/otherpage1.html',
            controller  : 'otherpage1Controller'
        })
        .when('/page2', {
            templateUrl : 'pages/otherpage2.html',
            controller  : 'otherpage2Controller'
        });
});

Check this Link : http://docs.angularjs.org/api/ngRoute .$routeProvider

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM