【发布时间】:2019-10-27 08:18:18
【问题描述】:
如何获得有效的 Angular 7 systemjs.config.js,详见文章:Setting Up Angular from Scratch 和 updated systemjs.config.js version for Angular 6。
我需要它才能将 Angular 7 UI 组件集成到我的 Scala Play 应用程序中,就像在 Angular 2 的种子 play-angular-typescript.g8 中所做的那样。请参阅 index.scala.html 中的 Scala Play 视图与 Angular 2 罪魁祸首的集成
@()
<!doctype html>
<html lang="en" data-framework="angular2">
<head>
<base href="/" />
@* In this version of the application the typescript compilation is done by the play framework.
The browser downloads .js files. *@
<meta charset="utf-8">
<title>Angular Tour of Heroes</title>
<link rel="stylesheet" href="assets/stylesheets/styles.css">
<script type='text/javascript' src='@routes.Assets.versioned("lib/core-js/client/shim.min.js")'></script>
<script type='text/javascript' src='@routes.Assets.versioned("lib/zone.js/dist/zone.js")'></script>
<script type='text/javascript' src='@routes.Assets.versioned("lib/systemjs/dist/system.src.js")'></script>
<script type='text/javascript' src='@routes.Assets.versioned("systemjs.config.js")'></script>
@* our app is downloaded as individual javascript files by SystemJs after compilation by sbt-typescript*@
<script>
System.import('assets/app/main.js').catch(function(err){ console.error(err); });
</script>
</head>
<body>
<my-root>Loading...</my-root>
</body>
</html>
这是systemjs.config.js,它允许将 Angular 2 加载到 Scala 视图中:
/**
* System configuration for Angular samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'assets/lib/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
'app': 'assets/app',
// angular bundles
'@angular/core': 'npm:angular__core/bundles/core.umd.js',
'@angular/common': 'npm:angular__common/bundles/common.umd.js',
'@angular/compiler': 'npm:angular__compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:angular__platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:angular__platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:angular__http/bundles/http.umd.js',
'@angular/router': 'npm:angular__router/bundles/router.umd.js',
'@angular/forms': 'npm:angular__forms/bundles/forms.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
defaultExtension: 'js',
meta: {
'./*.js': {
loader: 'assets/systemjs-angular-loader.js'
}
}
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);
我希望将现有的 Scala Play 应用程序作为主要 MVC,并仅在某些 Play 视图中使用 Angular 7 组件。
【问题讨论】:
标签: javascript angular playframework angular7