问题
Is it possible to import my other plunker as a library in a new plunker?
Say, I've built a few AngularJS directives in a plunker. Can I reuse them in my other plunkers?
回答1:
You absolutely can refer from one plunk to another, but the mechanics to do so are not very well exposed. Historically, Plunker didn't expose this to users by design.
In future versions, Plunks will be publishable as semver versioned packages to the package manager and this sort of thing will automatically be wired up for you.
To use the type of setup you propose in Plunker today, you can:
- Create your new directive as its own Plunk and make sure that it is saved. It doesn't matter if it is public or private.
- Note this new plunk's id as its latest saved version will be available at
http://run.plnkr.co/plunks/<plunkId>/[filename.ext]
- In your 2nd plunk, you can either:
- Add the directive to the package catalogue using the above url and then add that new package to your plunk; or
- Add the directive script directly to your
index.html
via a typical<script src="<url>"></script>
tag.
I think that better search capabilities (already in preview at http://explore.plunker.co) and this mechanism for publishing versioned plunks to the catalogue will allow some really cool and efficient workflows for the next generation of online prototyping.
来源:https://stackoverflow.com/questions/25957246/can-you-import-dependencies-from-your-other-plunks