如何在MVC6项目中安装Angular2?

时间:2015-11-08 18:40:17

标签: angularjs npm asp.net-core asp.net-core-mvc angular

我面临ASP.NET5 MVC6项目的问题。我一直在创建使用AngularJS创建单页面应用程序的项目。现在我想安装Angular 2而不是AngularJS 1.

那么我应该怎么做才能将项目从正常的AngularJS升级到Angular 2。

2 个答案:

答案 0 :(得分:1)

要配置基本应用程序,您需要包含angular2并配置system.js

以下是文档(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>

答案 1 :(得分:0)

由于Web根目录是wwwroot,因此无法访问wwwroot之外的任何文件或文件夹。 node_modules文件夹是wwwroot的兄弟 - 都在父项目文件夹下。

不幸的是,唯一的方法是将node_modules中的文件相应地复制到wwwroot中。

请务必更新systemjsconfig.js中的映射!

相关问题