Angular 2中的App卡在加载中

时间:2016-09-27 09:57:52

标签: angular

我一直在尝试使用npm start运行应用程序并显示我放在模板中的Html代码,但不起作用。 我的系统设置如下:

![Project Structure

app.component.ts:

   import { BrowserModule }    from '@angular/platform-browser'
   import { NgModule }         from '@angular/core';
   import { FormsModule }      from '@angular/forms';
   import { HttpModule }       from '@angular/http';

   import { AppComponent }     from './app.component';

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        FormsModule,
        HttpModule
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule {}

app.module.ts

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule }              from './app.module';

const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);

main.ts与Angular 2 Quickstart

相同
<html>
<head>
    <base href="/   ">
    <title>Proof of Concept v 0.0.2</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- 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>
        System.config({
            packages: {
                app: {
                    format: 'register',
                    defaultExtension: 'js'
                }
            }
        });
        System.import('app')
                .then(null, console.error.bind(console));
    </script>

</head>

<!-- 3. Display the application -->
<body>
<my-app>Loading...</my-app>
</body>

</html>

index.html从angular 2 Quickstart中提取

WHERE (@param='Y' AND field = @param ) OR  (@param='N' AND (field = @param OR field IS NULL))

检查浏览器控制台我看到以下错误: Browser console error

1 个答案:

答案 0 :(得分:0)

也许您错过了正确配置系统加载程序,即System.config

看看它是如何在systemjs.config.js中配置的 https://angular.io/guide/quickstart

您还可以查看systemjs配置文档 https://github.com/systemjs/systemjs/blob/master/docs/config-api.md