在Chrome打包应用中使用Angular 2

Viv*_*ndi 7 google-chrome-app angular

我正在尝试使用Angular 2创建一个chrome打包应用程序.但是当我尝试运行我的应用程序时出现以下错误:

EvalError:拒绝将字符串评估为JavaScript,因为'unsafe-eval'不是以下内容安全策略指令中允许的脚本源:"default-src'self'blob:filesystem:chrome-extension-resource

- >评估chrome-extension://aabbecghjjmmpbagelfmhllgaidcbnmn/app/boot.js

内容boot.js是:

System.config({ packages: { app: { format: 'register', defaultExtension: 'js', "defaultJSExtensions": true, } } });
System.import('app/boot').then(null, console.error.bind(console));
Run Code Online (Sandbox Code Playgroud)

我知道AngularJS(angular 1)有一个ng-csp指令来修复这个Content Security Policy错误.Angular 2有类似的东西吗?

有没有办法在打包的应用程序中运行Angular 2?

小智 0

使用 SystemJS Build https://github.com/systemjs/builder打包在一个应用程序文件中。

然后将其添加到index.html中,这样

<script src="angular2-polyfills.js"></script> 
<script src="app.min.js" ></script>
Run Code Online (Sandbox Code Playgroud)

你可以修复

EvalError:拒绝将字符串评估为 JavaScript,因为“unsafe-eval”不是以下内容安全策略指令中允许的脚本源:“default-src 'self' blob:文件系统:chrome-extension-resource

在manifest.json中使用沙箱https://developer.chrome.com/apps/manifest/sandbox