angular - Angular2 with Typescript - Error loading angular2/platform/browser -
i have spent way time on this, stuck , can't figure out how angular2 typescript run. keep getting 404 components:
error loading http://localhost:5000/angular2/platform/browser "angular2/platform/browser" http://localhost:5000/appscripts/boot.js
my index.html is:
<!doctype html> <html> <head> <meta charset="utf-8" /> <title>angular 2 asp.net core</title> <!-- 1. load libraries --> <script src="libs/es6-shim/es6-shim.min.js"></script> <script src="libs/zone.js/dist/zone.js"></script> <script src="libs/reflect-metadata/reflect.js"></script> <script src="libs/systemjs/dist/system.src.js"></script> <!-- 2. configure systemjs --> <script src="./appscripts/config.js"></script> <script> system.import('appscripts/boot') .then(null, console.error.bind(console)); </script> </head> <body> <my-app>loading...</my-app> </body> </html>
the boot.ts:
/// <reference path="../node_modules/angular2/typings/browser.d.ts" /> import {bootstrap} 'angular2/platform/browser' import {appcomponent} './app' bootstrap(appcomponent);
the app.ts:
/// <reference path="../typings/jquery/jquery.d.ts" /> /// <reference path="../typings/angularjs/angular-route.d.ts" /> /// <reference path="../typings/angularjs/angular.d.ts" /> import {component} 'angular2/core'; @component({ selector: 'my-app', template: 'my first angular 2 app' }) export class appcomponent { }
the config.js
(function (global) { // map tells system loader things var map = { 'app': 'appscripts', // 'dist', 'rxjs': 'libs/rxjs', 'angular2-in-memory-web-api': 'libs/angular2-in-memory-web-api', '@angular': 'libs/@angular' }; // packages tells system loader how load when no filename and/or no extension var packages = { 'app': { main: 'boot.js', defaultextension: 'js' }, 'rxjs': { defaultextension: 'js' }, 'angular2-in-memory-web-api': { defaultextension: 'js' }, }; var packagenames = [ '@angular/common', '@angular/compiler', '@angular/core', '@angular/http', '@angular/platform-browser', '@angular/platform-browser-dynamic', '@angular/router', '@angular/router-deprecated', '@angular/testing', '@angular/upgrade', ]; // add package entries angular packages in form '@angular/common': { main: 'index.js', defaultextension: 'js' } packagenames.foreach(function (pkgname) { packages[pkgname] = { main: 'index.js', defaultextension: 'js' }; }); var config = { map: map, packages: packages } // filtersystemconfig - index.html's chance modify config before register it. if (global.filtersystemconfig) { global.filtersystemconfig(config); } system.config(config); })(this);
here more of folder structure give better idea of project structure.
here package.json
{ "version": "1.0.0", "name": "asp.net", "private": true, "dependencies": { "@angular/common": "2.0.0-rc.1", "@angular/compiler": "2.0.0-rc.1", "@angular/core": "2.0.0-rc.1", "@angular/http": "2.0.0-rc.1", "@angular/platform-browser": "2.0.0-rc.1", "@angular/platform-browser-dynamic": "2.0.0-rc.1", "@angular/router": "2.0.0-rc.1", "@angular/router-deprecated": "2.0.0-rc.1", "@angular/upgrade": "2.0.0-rc.1", "systemjs": "0.19.27", "es6-shim": "^0.35.0", "reflect-metadata": "0.1.2", "rxjs": "5.0.0-beta.6", "zone.js": "^0.6.12", "angular2-in-memory-web-api": "0.0.7" }, "devdependencies": { "gulp": "^3.9.0", "gulp-autoprefixer": "~3.1.0", "gulp-concat": "~2.6.0", "gulp-imagemin": "~2.4.0", "imagemin-pngquant": "~4.2.0", "jshint": "2.9.2", "gulp-jshint": "2.0.0", "jshint-stylish": "~2.1.0", "rimraf": "~2.5.1", "gulp-minify-css": "~1.2.4", "gulp-sass": "2.2.0", "gulp-uglify": "~1.5.1", "gulp-sourcemaps": "~1.6.0", "gulp-plumber": "1.1.0", "gulp-notify": "2.2.0", "beepbeep": "1.2.0", "gulp-rename": "1.2.2", "gulp-sourcemap": "1.0.1", "gulp-clean-css": "2.0.6", "main-bower-files": "2.13.0", "gulp-filter": "4.0.0", "typescript": "^1.8.10", "gulp-typescript": "^2.13.1", "live-server": "1.0.0", "typings": "^1.0.4", "gulp-tsc": "^1.1.5" } }
thank in advance , please let me know if can provide more details.
you're using rc.1 version of angular trying import beta version.
you need use @angular/..
this:
import { bootstrap } '@angular/platform-browser-dynamic'; import { component } '@angular/core'; // instead of 'angular2/core' ....
for more details see changelog https://github.com/angular/angular/blob/master/changelog.md#200-rc0-2016-05-02
to import various symbols please adjust paths in following way:
angular2/core -> @angular/core angular2/compiler -> @angular/compiler angular2/common -> @angular/common angular2/platform/browser -> @angular/platform-browser + @angular/platform-browser-dynamic angular2/platform/server -> @angular/platform-server angular2/testing -> @angular/core/testing angular2/upgrade -> @angular/upgrade angular2/http -> @angular/http angular2/router -> @angular/router-deprecated (from beta.17 backwards compatibility) new package: @angular/router - component router several breaking changes