デフォルトのエクスプレスアプリケーションを生成しました。このアプリケーションでは、次の行をapp.js
ファイルに変更しました。 ./viewsディレクトリ内テンプレートエンジンなしでng2にルーティングする
app.set('views', path.join(__dirname, '/views'));
app.engine('html', require('jade').renderFile);
app.set('view engine', 'html');
、私はもともとlayout.jade
、index.jade
とerror.jade
を持っていました。 OK、これまでのところ良い。プロジェクトが実行されると、インデックスまたはエラーレイアウトが表示されます。
今、最小のangular2インストールを追加したいと考えています.ng2に1ページアプリケーションを管理させるために、index.jade
が現在あります。
だから私はapp.component.ts
入れている:その後、私はindex.html
にindex.jade
を変更して、コメントを追加し
import { bootstrap } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app.component';
bootstrap(AppComponent);
:
<html>
<head>
<title>Angular 2 QuickStart</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../public/stylesheets/style.css">
<!-- 1. Load libraries -->
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
</head>
<!-- 3. Display the application -->
<body>
<my-app>Loading...</my-app>
</body>
</html>
しかし、で
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: '<h1>My First Angular 2 App</h1>'
})
export class AppComponent { }
中とmain.ts
ファイルをhtmlテンプレートエンジンとm y new error.html
とindex.html
ファイルの場合、常にng2管理インデックスではなくエラーページが表示されます。なぜどんなアイデア?
これを把握しましたか?以下の提案ではejsと書かれていますが、私もテンプレートエンジンを使いたくありません。角度2セレクタを持つindex.htmlファイルを提供する正しい方法は何ですか。私は奇妙なエラーを出すことなく、フロントエンドを角度2に渡すことができます。ページをリフレッシュするときなど – wuno