Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

This seems like it should work no problem, yet it just doesn't.


So I'm using a very funky file / image upload provider GitHub - danialfarid/ng-file-upload: Lightweight Angular directive to upload files with optional FileAPI shim for cross browser support[^]

I am going to use this to allow my customers to choose their own logo and favicon.

They can preview the logo on the page by checking the preview checkbox. This will update the logo and favicon image on the page.

[Code below]

As per the "What I have tried" code comments: The image does not change!

I checked that the url is valid by adding it to the element via chrome inspector. No problems there.

So what am I doing wrong :S

Thanks
Andy

What I have tried:

The logo is on $(".main-logo") as a background image:

JavaScript
$scope.logoChanged = function () {
    Upload.dataUrl($scope.file, false).then((fileUrl) => { 
//fileUrl: "blob:https://d15461a6.ngrok.io/eb87daf2-8581-4a83-a4d4-35ed19e18903"
        if ($scope.file) {
                        
            const logo = $('.main-logo'); // logo div
            if ($scope.previewImage) { //checkbox model
                const url = 'url("'+fileUrl+'") !important';
                logo.css("background-image", url); 
//url: url("blob:https://d15461a6.ngrok.io/eb87daf2-8581-4a83-a4d4-35ed19e18903") !important
                console.log(logo.css("background-image"))
//logo.css("background-image"): url(/Resources/images/ebLicence.png)
            } else {
                logo.css("background-image", logoBgImage);
            }
        }
    });
}
Posted
Updated 20-Feb-17 0:15am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900