Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 616
dvdmn Avatar asked Jun 13 '13 19:06

dvdmn


1 Answers

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

like image 130
Michael Banzon Avatar answered Nov 16 '22 01:11

Michael Banzon