# Ng-if with includes method in template node?

**URL:** https://discourse.nodered.org/t/ng-if-with-includes-method-in-template-node/51284
**Category:** Dashboard
**Created:** [20 September 2021 11:16 UTC](https://discourse.nodered.org/t/ng-if-with-includes-method-in-template-node/51284 "2021-09-20T11:16:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![geoseph](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/geoseph/32/39526_2.png) [@geoseph](https://discourse.nodered.org/u/geoseph)
#### Post date: [20 September 2021 11:16 UTC](https://discourse.nodered.org/t/ng-if-with-includes-method-in-template-node/51284/1 "2021-09-20T11:16:39Z")

</div>

Hello everyone,

I have an array of objects that have URL properties, with values that contain [giphy.com](http://giphy.com) or [youtube.com](http://youtube.com)

I'm trying to present them as either an Image or a Embedded Video depending on their src.  
What am I doing wrong here?

```auto
  <div class="chime-img-wrap">
     <img ng-if="obj.link.includes(giphy)" src="{{obj.link}}" alt="" class="chime-img" >
     <iframe ng-if="obj.link.includes(youtube)" src="{{obj.link}}" class="chime-vid" width="320" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
  </div>

```

---

<div class="post-metadata">

### Author: ![geoseph](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/geoseph/32/39526_2.png) [@geoseph](https://discourse.nodered.org/u/geoseph)
#### Post date: [21 September 2021 04:22 UTC](https://discourse.nodered.org/t/ng-if-with-includes-method-in-template-node/51284/2 "2021-09-21T04:22:40Z")

</div>

I think i was encountering a cors issue when trying to dynamical construct an embedded youtube video because I couldn't ever get the thing to load even though i'm sure I had the html and properties and values correct.  
I opted to just handle .mp3, .mp4, .png, & .gif media urls instead.  
I used my `.includes()` method in a prior function node on the appropriate properties then passed them along to my template node that looked like (note this next code segment is inside a `ng-repeat`ing div)

```auto
  <div class="chime-img-wrap" ng-if="obj.isgif === true">
     <img src="{{obj.link}}" alt="" class="chime-img" >
  </div>
  
  <div class="chime-img-wrap" ng-if="obj.ispng === true">
     <img src="{{obj.link}}" alt="" class="chime-img" >
  </div>
  
  <div class="chime-img-wrap" ng-if="obj.ismp4 === true">
    <video width="320" height="240" controls>
     <source src="{{obj.link}}" type="video/mp4">
    </video>
  </div>
  
  <div class="chime-img-wrap" ng-if="obj.ismp3 === true">
    <audio controls>
     <source src="{{obj.link}}" type="audio/mp3">
    </audio>
  </div>

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [5 October 2021 04:23 UTC](https://discourse.nodered.org/t/ng-if-with-includes-method-in-template-node/51284/3 "2021-10-05T04:23:05Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
