long pham
long pham

Reputation: 37

Failed to load resource: net::ERR_FILE_NOT_FOUND but data is loaded

enter image description hereI have some error. this is my code. File html:

<div ng-controller="newsCtrl">
  <div class="row">
    <div ng-repeat="x in news">

      <div class="col-xs-6">
        <div class="newsContent">{{x.content}}</div>
        <div class="newsImage"><img src="../image/{{x.image}}" alt="vinfast oto"></div>
        <div class="newsTitle">
          <h2>{{x.title}}</h2>
        </div>
      </div>
      <hr>
    </div>
  </div>
</div>

File app.js:

app.controller("newsCtrl", function ($scope, $http) {
  $http({
    method: "GET",
    url: "http://localhost:8080/EX11_29112018_spring_restful/news"
  }).then(function (response) {
    $scope.news = response.data;
  })
});

Html in views folder, app.js in js folder, they are in webapp folder. My image is loaded, but I have this error: Failed to load resource: net::ERR_FILE_NOT_FOUND; How to fix it.

Upvotes: 1

Views: 1031

Answers (1)

Yogen Rai
Yogen Rai

Reputation: 3033

The ngSrc directive solves this problem. So change

<img src="../image/{{x.image}}" alt="vinfast oto">

to correct way as:

<img ng-src="../image/{{x.image}}"></img>

Find more about ngSrc here.

Upvotes: 1

Related Questions