Angular 2.0 - custom build/ import and use an “on

2019-09-07 03:26发布

问题:

I want to play with integrating Angular 2.0 components inside an Angular 1.X project, using the upgrade module.

I figured out that this module is not public/available for import in Alpha 44.

I was wondering how can I build Angular2 locally + export this module so I'll be able to import it on my local project? (I guess I should dig inside their gulp/build in order to figure this out)

回答1:

Update 18/11/2015

Since alpha 46 ngUpgrade is already available, so the below steps are no longer necessary.

Update 30/10/2015

As of today the commit referenced in the original answer was merged to the main repository. So you can skip some of those steps and build it following the Developer guide.

Original answer

Well, I found a way. First note that Misko commited ngUpgrade to angular2's main repo but it's still not merged, so these few steps will change in a short time, I think.

Steps :

  • Clone Misko's repo
  • Change to imports branch
sudo git checkout imports
  • Install dependencies
npm install
  • Build
// This will build only the js files
$(npm bin)/gulp build.js  

// or both js and dart files
//$(npm bin)/gulp build

After all these steps you'll have the bundles under

angular/dist/js/bundle

Here's a plnkr with the minified bundle added manually.

I hope this is what you are looking for :)