I am attempting to get the Quick Start to run in Visual Studio 2015 using ASP-5 Empty Template. I downloaded the angular2 and systemjs last week.
The problem I am getting is when I run it as it with this piece of code in the html.index
<script>
System.config({
packages: { 'app': { defaultExtension: 'js' } }
});
System.import('app/app');
</script>
I receive the following error
0x800a1391 - JavaScript runtime error: 'System' is undefined
This is highlighted: System.config({
packages: { 'app': { defaultExtension: 'js' } }
});
If I remove the code above and replace it with
<script src="app/app.js"></script>
0x800a1391 - JavaScript runtime error: 'require' is undefined
Inside the App.ts file the following line of code is highlighted: import {Component, View, bootstrap} from 'angular2/angular2';
Folder Layout
Project Folder
- Node_Modules
- angular2 (install via 'npm install angular2'
- systemjs (installed via 'npm install systemjs')
- src
- WebApplication6
- Node_Modules
- angular2
- bundles
- typings
- angular2
- angular2.d.ts
- http.d.ts
- router.d.ts
- testing.d.ts
- es6-shim
- jasmine
- angular2.dev.ts
- systemjs
- Scripts
- wwwroot
Index.html File *Note I have replaced the script source files with the ones provided on the
angular.io page and get the exact same results.
<!DOCTYPE html>
<html>
<head>
<title>Angular 2 QuickStart</title>
<script src="../node_modules/systemjs/dist/system.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>
app.ts
/// <reference path="../node_modules/angular2/bundles/typings/angular2/angular2.d.ts" />
import {Component, View, bootstrap} from 'angular2/angular2';
@Component({
selector: 'my-app'
})
@View({
template: '<h1>Hello {{ name }} </h1>'
})
class AppComponent {
name: string;
constructor() {
}
}
bootstrap(AppComponent);
tsconfig.json
/// <reference path="../node_modules/angular2/bundles/typings/angular2/angular2.d.ts" />
import {Component, View, bootstrap} from 'angular2/angular2';
@Component({
selector: 'my-app'
})
@View({
template: '<h1>Hello {{ name }} </h1>'
})
class AppComponent {
name: string;
constructor() {
}
}
bootstrap(AppComponent);
startup.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.Framework.DependencyInjection;
namespace WebApplication6
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
}
public void Configure(IApplicationBuilder app)
{
// Add the platform handler to the request pipeline.
app.UseIISPlatformHandler();
app.UseDefaultFiles();
app.UseStaticFiles();
}
}
}
Any thoughts would greatly be appreciated