Can you import dependencies from your other plunks?

与世无争的帅哥 提交于 2019-12-08 06:11:20

问题


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:

  1. 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.
  2. Note this new plunk's id as its latest saved version will be available at http://run.plnkr.co/plunks/<plunkId>/[filename.ext]
  3. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!