Trying to enhance my AngularJS app by incorporating an image from a random cat image site, using the URL received. Below is the snippet from my controller.js:
'use strict';
/* Controllers */
var catPath = "http://thecatapi.com/api/images/get?format=src&results_per_page=1";
var Controllers = angular.module('museum1.controllers', []);
Controllers.controller('oneCatController', ['$scope', '$http',
function($scope, $http) {
$http.get(catPath).success(function(data) {
$scope.imgurl = data;
console.log($scope.imgurl);
});
}]);
Here's the partial that should display the cat image fetched:
<div>
<img ng-src="{{imgurl}}">
</div>
The controller is called from app.js, not shown here.
While inspecting with fireBug, I noticed a message indicating the path requested and "302 Found 770ms". Interestingly, the same path works when accessed directly from the browser address bar. The Angular code was successful for me using this example.