asp.net - Angular 2 import error with RequireJS -


i'm unable import angular2/core due following error:

module name "angular2/core" has not been loaded yet context: _. use require([]) 

this typescript file:

import {component, view} "angular2/core"; import {bootstrap} "angular2/platform/browser"; @component({           selector: "menu" }) class menucomponent { isactive(path: string) {     return true    } } bootstrap(menucomponent); 

which compiled configuration:

{     "compileroptions": {     "noimplicitany": false,     "noemitonerror": true,     "removecomments": true,     "sourcemap": true,     "target": "es5",     "module": "commonjs",     "outdir": "../wwwroot/js",     "experimentaldecorators": true,     "emitdecoratormetadata": true   },     "exclude": [     "node_modules",     "wwwroot"   ] } 

this compiled javascript file:

var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = object.getownpropertydescriptor(target, key) : desc, d; if (typeof reflect === "object" && typeof reflect.decorate === "function") r = reflect.decorate(decorators, target, key, desc); else (var = decorators.length - 1; >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && object.defineproperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof reflect === "object" && typeof reflect.metadata === "function") return reflect.metadata(k, v); }; var core_1 = require("angular2/core"); var browser_1 = require("angular2/platform/browser"); var menucomponent = (function () { function menucomponent() { } menucomponent.prototype.isactive = function (path) {     var page = window.location.pathname;     if (path === undefined || path === '') {         path = '';     }     var result = path === '' ? path === page[page.length - 1] : page[page.length - 1].indexof(path) > -1;     return result; }; menucomponent = __decorate([     core_1.component({         selector: "menu"     }),      __metadata('design:paramtypes', []) ], menucomponent); return menucomponent; })(); browser_1.bootstrap(menucomponent); //# sourcemappingurl=menu.js.map 

my javascript imported in order:

<script type="text/javascript" src="~/lib/requirejs/require.js"></script> <script type="text/javascript" src="~/lib/angular2-polyfills.js"></script> <script type="text/javascript" src="~/lib/es6-shim.js"></script> <script type="text/javascript" src="~/lib/system-polyfills.js"></script> <script type="text/javascript" src="~/lib/angular2-polyfills.js"></script> <script type="text/javascript" src="~/lib/system.src.js"></script> <script type="text/javascript" src="~/lib/rx.js"></script> <script type="text/javascript" src="~/lib/angular2.js"></script> <script type="text/javascript" src="~/js/menu.js"></script> 

i wondering what's causing above error. since i'm unable change javascript code compiled typescript file.

i'm using visual studio 2015 asp.net 5. know angular 2 still in beta , asp.net 5 still in rc, doubt combination causing issue.

thanks help.

i think use 2 module loaders, requirejs , systemjs. see included in html file:

<script type="text/javascript" src="~/lib/requirejs/require.js"></script> <------ <script type="text/javascript" src="~/lib/angular2-polyfills.js"></script> <script type="text/javascript" src="~/lib/es6-shim.js"></script> <script type="text/javascript" src="~/lib/system-polyfills.js"></script> <script type="text/javascript" src="~/lib/angular2-polyfills.js"></script> <script type="text/javascript" src="~/lib/system.src.js"></script> <------ <script type="text/javascript" src="~/lib/rx.js"></script> <script type="text/javascript" src="~/lib/angular2.js"></script> <script type="text/javascript" src="~/js/menu.js"></script> 

you need one. example systemjs. that's reason of message. both libraries try load angular2/core module...

edit

if want use systemjs only, update tsconfig.json file:

{     "compileroptions": {     "noimplicitany": false,     "noemitonerror": true,     "removecomments": true,     "sourcemap": true,     "target": "es5",     "module": "system",  <--------     "moduleresolution": "node",   <--------     "outdir": "../wwwroot/js",     "experimentaldecorators": true,     "emitdecoratormetadata": true   },     "exclude": [     "node_modules",     "wwwroot"   ] } 

hope helps you, thierry


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -