David Duman
David Duman

Reputation: 6656

ng repeat template causes 404 (Not Found)

I've a ng repeater and I defined a list item template for an article list page:

  <ul class="article_list">
    <li ng-repeat="article in articles | filter:search">
      <a href="#" title="article title here">
        <span class="date">
          <span class="month">{{ article.dt_month }}</span>
          <span class="day">{{ article.dt_day }}</span>
          <span class="year">{{ article.dt_year }}</span>
        </span>
        <img src="images/news/{{ article.id }}.jpg" alt="{{ article.title }}" class="thumb" />
        <div class="summary">
          <span class="article_title">{{ article.title }}</span>
          <span class="short">{{ article.content }}...</span>
        </div>
      </a>
    </li>
    <li ng-show="(articles | filter:search).length==0">No article found</li>
  </ul>

When I checked the console I see 404 not found error for the file images/news/{{article.id}}.jpg

How can I prevent this issue?

Thanks

Upvotes: 16

Views: 3265

Answers (1)

Michael Banzon
Michael Banzon

Reputation: 4967

Use ng-src instead of src for image resources. That way the browser will load it when model data is available.

Upvotes: 50

Related Questions