0

I'm stuck with an anchor that sets the ng-href to a server-stored variable and let's say, 1 in 300 return a 404 and that source is out of my hands to control.

<div class="steam-slide">
    <div class="steam-slide-poster-img-wrapper">
        <a ng-if="!mobileType" class="steam-slide-poster-img" ng-href="{{steamer.portUrl}}">{{steamer.description}}</a>
        <a ng-if="ismobileType" class="steam-slide-poster-img" ng-href="{{steamer.landUrl}}">{{steamer.description}}</a>
    </div>
</div>

What happens is steamer.portURL sometimes returns a 404 and that crashes the whole template. I've written a 404 check server side but it takes too long and causes a timeout due to a large amount of records being requested. I also can't reduce that number. Is there a good way to check for the URL being 'good' and doing an ng-if or ng-switch so the template doesn't crash entirely?

Also I cannot call from Javascript because of CORS is in effect...

Thanks...

infused
  • 24,000
  • 13
  • 68
  • 78
Mike
  • 1
  • 1
  • As far as I know there's no way to test a url. However, you could probably make an $http request and timeout with an error before loading the page. Put a flag - and if it timed out, use the flag as an ng-if. Does that make sense? – itamar Dec 17 '15 at 21:54
  • It does and it's what I resorted to. And so far so good. I was hoping to discover something more elegant, but you can't always get what you want. – Mike Dec 18 '15 at 23:33
  • 1
    That's okay. If you try sometimes you just might find you get what you need. – itamar Dec 19 '15 at 06:15
  • - The Philosopher Jagger – Mike Jul 30 '18 at 14:29

0 Answers0