Quando tento buscar as fotos no servidor aparece a seguinte mensagem no navegador:
GET file:///C:/Users/Cleber%20Carvalho/Desktop/JS%20Alura/Angular/alurapic/public/%7B%7Bfoto.url%7D%7D net::ERR_FILE_NOT_FOUND
angular.min.js:87 XMLHttpRequest cannot load file:///C:/v1/fotos. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
(anonymous) @ angular.min.js:87
n @ angular.min.js:82
f @ angular.min.js:80
(anonymous) @ angular.min.js:112
$eval @ angular.min.js:126
$digest @ angular.min.js:123
$apply @ angular.min.js:126
(anonymous) @ angular.min.js:17
e @ angular.min.js:36
d @ angular.min.js:17
uc @ angular.min.js:18
Jd @ angular.min.js:17
(anonymous) @ angular.min.js:250
a @ angular.min.js:164
c @ angular.min.js:32
fotos-controller.js:10 null
HTML:
<!DOCTYPE html>
<html lang="pt-br" ng-app="alurapic">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>Alurapic</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<script src="js/lib/angular.min.js"></script>
<script src="js/main.js"></script>
<script src="js/controllers/fotos-controller.js"></script>
</head>
<body ng-controller="FotosController">
<div class="container">
<div class="jumbotron">
<h1 class="text-center">Alurapic</h1>
</div>
<div class="row">
<div class="panel panel-default col-md-2" ng-repeat="foto in fotos">
<div class="panel-heading">
<h3 class="panel-title text-center">{{foto.titulo}}</h3>
</div>
<div class="panel-body">
<img class="img-responsive center-block" src="{{foto.url}}">
</div><!-- fim panel-body -->
</div><!-- fim panel panel-default -->
</div><!-- fim row -->
</div><!-- fim container -->
</body>
</html>
Controle:
angular.module('alurapic').controller('FotosController', function($scope, $http) {
$scope.fotos = [];
$http.get('/v1/fotos')
.success(function(fotos) {
$scope.fotos = fotos;
})
.error(function(erro) {
console.log(erro);
});
});