Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • james 37 posts 121 karma points c-trib
    Oct 28, 2014 @ 11:01
    james
    0

    Reusing libraries between packages

    Hello,

    I'm developing a custom section for the back office where I'd like to use the ng-table Angular library. We're already using the Trace Log Viewer package which also uses ng-table. Do I need to declare ng-table in my package.manifest or will it be ready to use as it's already been declared elsewhere? I'd rather not declare the same thing twice if I don't need to!

    Cheers!

  • Chris Randle 67 posts 181 karma points c-trib
    Mar 19, 2015 @ 15:41
    Chris Randle
    0

    Hi

    Let's see. Based on that you should get your answer - no - you don't need to put it in your manifest if something else is loading it for you (e.g. diplotracelogviewer). A word of advice if I may: if you are asking somebody "what happens when I do A" then doesn't it make more sense to do A and see? This is a good rule-of-thumb for development. Try it out first and then come back if it doesn't work.

    Just put the ng-table attribute on your table, along with the data-title attribute on each td. If you get the ng-table's table headings - then you don't need to add it to your package.manifest!**

    Have fun!

  • Matt Brailsford 3291 posts 17432 karma points MVP 8x c-trib
    Mar 20, 2015 @ 23:27
    Matt Brailsford
    0

    I guess it's a question of, will other people possibly install your package that won't have Trace Log Viewer installed and so therfore won't have ng-table included?

    If it's just for yourself, and you know it will always be installed already, then yes, you could just leave it out and it should be loaded already by Trace Log Viewer for you. If the answer is no, and you want to make your package installable by others who might not have Trace Log Viewer installed, then you'll need to load it yourself.

    Assuming you are loading some main js file for you own package, what you could do instead of loading it from your package manifest, is to add some logic to your main script file to test whether ng-table is loaded, and if not, load it. This would be the optimal solution as it loads it if it needs loading, but doesn't bother if it's already loaded.

    Checkout the docs for the assetService for an easy way to load js / css files on the fly, rather than registering them globally in your package.manifest

    http://umbraco.github.io/Belle/#/api/umbraco.services.assetsService

    Hope this helps.

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft