Copied to clipboard

Flag this post as spam?

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


  • Paul de Quant 403 posts 1520 karma points
    Feb 17, 2020 @ 13:34
    Paul de Quant
    0

    AngualrJS determine if id belongs to media or content

    Hello,

    Is there a way in AngualrJS to determine if an ID belongs to an Umbraco media item or content item.

    I'm using contentResource.getById and mediaResource.getById, but I'm looking for a clean way to determine which of these I should call. As one of these will throw an error .

    Thanks Paul

  • Kevin Jump 2309 posts 14673 karma points MVP 7x c-trib
    Feb 17, 2020 @ 13:58
    Kevin Jump
    0

    Hi Paul,

    I use the application value in the metaData.

    e.g assuming vm.entity is the "content" object you are working with.

    vm.isMedia = vm.entity.metaData.application === 'media';
    
Please Sign in or register to post replies

Write your reply to:

Draft