Understanding AngularJS ng-src

Put the whole path inside the $scope variable. That way ng-src will wait until you provide it with the fully resolved path to the image:

<div ng-controller="MyCtrl">
  <img ng-src="https://stackoverflow.com/questions/18235169/{{ path }}" />
</div>
function MyCtrl($scope, $timeout) {
    var path="https://si0.twimg.com/profile_images/";
    $timeout(function () {
        $scope.path = path + '2149314222/square.png';
    }, 1000);
};

FIDDLE

Leave a Comment