[英]How to install Angular2 in MVC6 Project?
I'm facing problem with ASP.NET5 MVC6 project. 我面临着ASP.NET5 MVC6项目的问题。 I have been create project that's using AngularJS to create Single Page Application.
我一直在创建使用AngularJS创建单页面应用程序的项目。 Now I want to install Angular 2 instead of AngularJS 1.
现在我想安装Angular 2而不是AngularJS 1。
So what should I do to upgrade the project from normal AngularJS to Angular 2. 那么我该怎么做才能将项目从普通的AngularJS升级到Angular 2。
To get a basic application configured you need to include angular2 and configure system.js 要配置基本应用程序,您需要包含angular2并配置system.js
Here is an example from the documentation ( https://angular.io/guide/quickstart ): 以下是文档( https://angular.io/guide/quickstart )中的示例:
<html>
<head>
<title>Angular 2 QuickStart</title>
<script src="../node_modules/systemjs/dist/system.src.js"></script>
<script src="../node_modules/angular2/bundles/angular2.dev.js"></script>
<script>
System.config({
packages: {'app': {defaultExtension: 'js'}}
});
System.import('app/app');
</script>
</head>
<body>
<my-app>Loading...</my-app>
</body>
</html>
Since the web root is wwwroot, no files or folders outside of wwwroot can be accessed. 由于Web根目录是wwwroot,因此无法访问wwwroot之外的任何文件或文件夹。 The node_modules folder is a sibling of wwwroot - both under the parent project folder.
node_modules文件夹是wwwroot的兄弟 - 两者都在父项目文件夹下。
Unfortunately, the only method is to copy the files from node_modules into wwwroot accordingly. 不幸的是,唯一的方法是将node_modules中的文件相应地复制到wwwroot中。
Be sure to update the mappings in systemjsconfig.js! 一定要更新systemjsconfig.js中的映射!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.