0

I have troubles trying to use angular2 components in an an ES5 angularJS application with requireJS. When i use angular2.dev.sfx.js then i can use follwing code for bootstrapping:

define([
'nxApp',
'nxRoute',
 ], 
   function(nxApp, nxRoute){
     var upgradeAdapter = new ng.UpgradeAdapter();
     upgradeAdapter.bootstrap(document.body, ['nxApp']);
     return upgradeAdapter;
});

But then i cannot make use of import {Component} from 'angular2/angular2' in typescripts, because this translates to define(['angular2/angular2']... which in turn results in a script error as the script can not be loaded beacuse requireJS searches for angular2.js in the app root folder but it does not exist there.

When I use angular2.dev.js and system.js then the TypeScripts work but i cannot get a reference for angular 2 in my es5 bootsrapping code. ng ist not defined anymore an trying to place angular2/angular2 in the define throws me ann error that the common module has not been loaded.

Is it possible at all to use angular2 typescript components in a ES5 application?

Thanks.

1 Answer 1

1

I had to convert the ES5 Javascript part to make use of System.js. It has a similar configuration to RequireJs, the shims had to be replaces by meta.

With that i could load angular2.dev.js and system.js as it is shown in the angular 2 Quickstart. require('angular2/angular2') could then be used to get angular2 from within ES5 javascript.

Sign up to request clarification or add additional context in comments.

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.