2016-11-12 62 views
1

我正在做一个简单的角度2教程,但我只是'试图运行我的应用程序时'加载'。 这是我的index.html文件角度2应用程序组件不加载

<html> 
     <head> 
     <title>Angular CV </title> 
     <base href="/"> 
     <meta charset="UTF-8"> 
     <meta name="viewport" content="width=device-width, initial-scale=1"> 
     <link rel="stylesheet" href="styles.css"> 
     <!-- 1. Load libraries --> 
     <!-- Polyfill 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>Still Loading...</my-app> 
     </body> 
    </html> 

app.component.ts

 

    import { Component } from '@angular/core'; 

    @Component({ 
     selector: 'my-app', 
     template: '' 
    }) 
    export class AppComponent { 

    } 

完整的代码在这里:https://github.com/trinajoy/angularcv

+0

控制台中是否有错误? – echonax

+0

你应该做npm install reflect-metadata和npm install reflect-portfinder。 –

+0

在铬开发工具我得到以下错误 shim.min.js:2未捕获的SyntaxError:意外令牌< (为之前的代码线) 和index.html的 本地主机/:18未捕获的ReferenceError:系统没有定义(...) System.import('app')。catch(function(err){console.error(err);}); 和 directive_normalizer.js:92未被捕获的错误:模板解析错误:(...) - 但我不知道它指的是哪部分代码... – user6086008

回答

0

Angular-cli改变了他们的系统从SystemJS到的WebPack因为beta.14。不过,你似乎还在使用SystemJS。

您可以在these instructions之后迁移到Webpack。但是,由于您只是按照教程,我建议install angular-cli from scratch

+0

以及我做了以下npm卸载-g角度cli,npm缓存干净,npm安装-g角度cli @最新,并再次启动,但从我什么我看到,我在我的json文件中也有相同的信息,还有angular-cli json,我仍然得到相同的观点,我的应用程序只显示索引文件中的“加载”。 github.com/trinajoy/angulartest.git 我有一些教程即使尝试 – user6086008

+0

同样的问题但你仍然试图导入'SystemJS'在你的'index.html'(17-19行)(和也试图加载SystemJS脚本)。 – brians69

+0

so im donig - npm uninstall -g angular-cli,npm cache clean,npm install -g angular-cli @ latest - 还没有得到beta 14 ..?我没有做对吗? – user6086008