我是Angular2的新手,並打算在github頁面上創建一個小的Angular2應用程序(當前爲helloworld)。github頁面上的Angular2應用程序的路徑問題
我通過angular-cli
創建了ng2-lite
,託管在site。部署由angular-cli
提供。它部署到gh-pages
分支進行顯示。
最近我發現了angular-cli
以外的另一種方式。我創建了ng2-raw
從頭開始使用類似的代碼,但沒有任何部署操作,託管在site
但是,我創建ng2-raw
時遇到了一些問題。調試完成後,找不到css
或html
的相對路徑(與ts
的路徑相同),所以我修改了路徑使其工作。
github.com/MoYummy/ng2-lite/blob/master/src/app/hello.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'hello',
templateUrl: './hello.component.html',
styleUrls: ['./hello.component.css']
})
export class HelloComponent {
name: string = 'World';
}
github上:
請我的兩個回購檢查出不同的代碼.COM/MoYummy/NG2-RAW/BLOB/GH-頁/的HelloWorld /應用/ hello.component.ts
import {Component} from 'angular2/core';
@Component({
selector: 'hello',
templateUrl: './app/hello.component.html',
styleUrls: ['./app/hello.component.css']
})
export class HelloComponent {
name: string = 'ng2';
}
爲什麼我必須更新這些路徑?如果將來代碼結構變得複雜,或者如果我嘗試將一個組件移動到子文件夾,該怎麼辦?
部署我的Angular2應用程序的兩種方式有什麼區別?