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 394 posts 1477 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 1867 posts 11859 karma points MVP 4x 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';
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies