簡體   English   中英

Angular js從哪個文件開始執行?

[英]From which file does Angular js execution start?

我有一個有角度的js項目。 我下載了種子項目並進行了一些更改。 我能夠運行它。 啟動服務器時,我必須手動轉到localhost:portnum / app / index.html來運行index.html”

當我鍵入localhost / portnum時,應如何配置它,它應該直接重定向到index.html。 我經歷了許多棱角分明的項目。 我無法理解角度執行從哪里開始。 我的意思是,執行從哪里開始。 js文件很多。 在這方面請提供幫助。

薩巴里斯里·蘇布拉瑪尼揚

我同意這不是一個尖銳的問題。 您的網絡服務器會將您告訴它的所有目錄都放置到​​網站/應用程序的根目錄。 一種可以處理此問題的非常簡單的方法(這是在localhost上進行測試時要做的事情):

如果您已安裝python,請使用python簡單的http服務器:

首先進入您的應用目錄:

cd /app

然后從該目錄內部運行python簡單的http服務器:

python -m SimpleHTTPServer 8080

服務器足夠聰明,知道index.html是它應該加載的第一頁,因此,現在要做的就是轉到瀏覽器並鍵入:

http://localhost:8080

完成。

還有其他Web服務器將完成相同的任務。 要記住的重要一點是,它將在您指定為根文件夾的任何文件夾中查找。 通過在/ app文件夾中啟動python簡單服務器,該文件夾將被設置為根目錄。 大多數Web服務器僅從“索引”的常用用法就知道index.html是站點的首頁。

祝好運!

使用如下路線

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'
        });
});

檢查此鏈接: http ://docs.angularjs.org/api/ngRoute。$ routeProvider

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM