5

I'm facing problem with ASP.NET5 MVC6 project. I have been create project that's using AngularJS to create Single Page Application. Now I want to install Angular 2 instead of AngularJS 1.

So what should I do to upgrade the project from normal AngularJS to Angular 2.

4
  • 5
    Angular is JS - you don't "install" JS Commented Nov 8, 2015 at 18:42
  • Use Nuget package manager to add angularjs package, it'll add the necessary js files to your project, you still need to make sure you're loading the js files on the html pages. Commented Nov 8, 2015 at 19:09
  • I'm stuck at the same point. I have installed Angular2 using npm. Now I want the angular2 files to appear inside the wwwroot/lib folder, the same way Bower does. I think we have to add a Gulp task to copy the files from the node_modules folder to the lib folder. Commented Nov 21, 2015 at 3:26
  • That is exactly what you have to do: create a Gulp task to copy files from node_modules to a folder in wwwroot, such as lib. Commented Oct 10, 2016 at 21:23

2 Answers 2

1

To get a basic application configured you need to include angular2 and configure system.js

Here is an example from the documentation (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>
Sign up to request clarification or add additional context in comments.

1 Comment

I'm using TypeScript with angular. I have been setup the project as I see inside the documentation and I have problem with call .ts file the browser console give me error said "app.ts is not found" the normal path inside project it's "wwwroot/js/app.ts".
0

Since the web root is wwwroot, no files or folders outside of wwwroot can be accessed. The node_modules folder is a sibling of wwwroot - both under the parent project folder.

Unfortunately, the only method is to copy the files from node_modules into wwwroot accordingly.

Be sure to update the mappings in systemjsconfig.js!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.