2016-06-10 143 views
0

我有一个角2应用程序,我使用的角度CLI发生器内置:https://github.com/EdmundMai/angular-2-playingRails:如何在视图中加载我的本地Angular 2应用程序?

这是发电机:https://github.com/angular/angular-cli

我跑ng serve,现在我有一个网页,我可以看到,当我访问http://localhost:4002

我DIST/index.html的在角2 app文件看起来是这样的:

<!doctype html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title>AngularTwo</title> 
    <base href="/"> 

    <script src="/ember-cli-live-reload.js" type="text/javascript"></script> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="icon" type="image/x-icon" href="favicon.ico"> 
    <script src="http://carbon.ec2.crowdtap.com/component_importer.js"></script> 
</head> 
<body> 
    <angular-two-app>Loading...</angular-two-app> 



    <script src="vendor/es6-shim/es6-shim.js"></script><script src="vendor/reflect-metadata/Reflect.js"></script><script src="vendor/systemjs/dist/system.src.js"></script><script src="vendor/zone.js/dist/zone.js"></script> 
    <script> 
     System.import('system-config.js').then(function() { 
     System.import('main'); 
     }).catch(console.error.bind(console)); 
    </script> 





</body> 
<script> 
    window.carbon.importComponents({ components: ['ct-button', 'ct-button/ct-button-link', 'ct-dialog', 'ct-progress'] }); 
</script> 
</html> 

在我的轨道查看,我想包括这些JS文件:

<script src="http://localhost:4200/vendor/es6-shim/es6-shim.js"></script> 
<script src="http://localhost:4200/vendor/reflect-metadata/Reflect.js"></script> 
<script src="http://localhost:4200/vendor/systemjs/dist/system.src.js"></script> 
<script src="http://localhost:4200/vendor/zone.js/dist/zone.js"></script> 
<script src="http://localhost:4200/system-config.js"></script> 
<script src="http://localhost:4200/main.js"></script> 

但是,它不工作,并抱怨main.ts:1Uncaught ReferenceError: require is not defined

是否有这样做的正确方法?

回答

0

需要在生成的

DIST改变<base href="/">标签(第6行)/ index.html中

<script>document.write('<base href="' + document.location + '" />');</script>

相关问题