Reputation: 1353
I have uploaded an image using AngularJs on a particular path. Now I want to display uploaded Single image in a div from that path.
Please help me to know how to display uploaded image?
In my AngularJs Controller:
$scope.uploadUrl = function () {
var url = "~/uploads";
}
And in view;
<div ng-controller="FileUploadController">
<input type="file" name="myFile" file-upload/>
<button ng-click="uploadFile()">Upload</button>
<div>
<div>
<img src="http://{{uploadUrl}}"/>
<img ng-src="http://{{uploadUrl}}"/>
</div>
I want to display image on click of upload button so that it could display image after uploading.
Upvotes: 0
Views: 1931
Reputation: 7172
hope this will help-
html-
<div ng-app="myApp">
<div ng-controller="myCtrl">
<img src="http://{{url}}"/>
<img ng-src="http://{{url}}"/>
</div>
</div>
and controller-
var myApp = angular.module('myApp', []);
myApp.controller('myCtrl',
function ($scope) {
$scope.url = 'cdn1.www.st-hatena.com/users/ho/howdy39/profile.gif';
}
);
Upvotes: 1