4

Angular バージョン 2 の開発者プレビューでテストしており、pub serve を使用して提供しています

次のように /lib/ 内のファイルを構造化する規則を確立したいと思います。

└── project/lib/root
    ├── root.css
    ├── root.dart
    └── root.html
└── project/web/
    ├── index.html
    └── index.dart

/web/index.dart ファイルで、root.dart から @View と @Component を正常に初期化できます

ただし、pub serve を介して Dartium でプレビューすると、/lib/root/root.html を提供できないようです。

@Component(
    selector: 'jroot'
)
@View(
    templateUrl: '../../lib/root/root.html',
    directives: const [If]
)
class Root {
  String content = 'Root - This is the entry point to the component';
  List<Times> list;

  Root(){
    print('RootComponent Init');
  }
}

Dartium コンソール:

GET http://localhost:8080/lib/root/root.html 404 (Not Found)

ここでポリマーのドキュメントを読んでいます。

「lib の下にある非 Dart ファイルは、lib の下にアセットをインポートするために相対パスを使用する必要があります:」

https://www.dartlang.org/polymer/app-directories.html

<!-- lib/a5/a6/a6.html imports lib/a4.html -->
<link rel="import" href="../../a4.html">

Python のシンプルな Web サーバーの実行は機能しているように見えるため、問題は pub serve にあります。

python -m SimpleHTTPServer

質問: lib フォルダーからネストされた html ファイルを操作するには、configure pub サービスをどのように使用しますか?

4

1 に答える 1

3

pubspec.yaml トランスフォーマーに適切なエントリ ポイントがあることを確認します。

name: 'project'
version: 0.0.1
dependencies:
  angular2: '2.0.0-alpha.23'
  browser: any
transformers:
- angular2:
    entry_points:
        - web/index.dart  //this
    reflection_entry_points:
        - web/index.dart  //this

それから私はこれがうまくいくはずだと思う

templateUrl: 'packages/project/root/root.html',

あるいは単に

templateUrl: 'root.html',
于 2015-05-17T15:28:00.113 に答える