I have this code straight from the documentation of Firebase :
// Create a reference to the file we want to download
var user = firebase.auth().currentUser.uid;
var storageRef = firebase.storage();
var pathReference = storageRef.ref('/' + user + '/profilePicture/' + image.name);
//var starsRef = storageRef.child('/' + user + '/profilePicture/' + file.name);
// Get the download URL
pathReference.getDownloadURL().then(function(url) {
// Insert url into an <img> tag to "download"
$scope.imageUrl = url;
console.log($scope.imageUrl);
});
But I can not figure what to write in my html file in order to get the image showing... Any help ?
Just put your result inside a variable of your controller and in ng-src on the HTML.
The best would be to use a service to get the URL and not directly in the controller.
Controller
app.controller('MyController', ['$scope', function($scope) {
// Create a reference to the file we want to download
var user = firebase.auth().currentUser.uid;
var starsRef = storageRef.child('/' + user + '/profilePicture/' + file.name);
// Get the download URL
starsRef.getDownloadURL().then(function(url) {
// Insert url into an <img> tag to "download"
$scope.imageUrl = url;
});
}]);
HTML
<img ng-src="{{imageUrl}}"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.