transmit a binary image to a modal using Angular

I am facing an issue with my code where I am unable to pass a binary image to a modal. The image displays correctly as a jpeg in the view, and I need it to display the same way in the modal as well.

View

  <h4 style="color: #3953a5; font-size:22px;"><strong>{{item.ItemName}}</strong></h4>
    <a ng-click="getIceDesignImage('data:image/jpg;base64,'+item)"><img src="{{'data:image/jpg;base64,'+item.Image}}" style="height:150px; width:150px;" alt="post img" class="pull-left img-responsive thumb margin10 img-thumbnail"></a>

    <h5 style="font-size:18px"><strong>${{item.ItemPrice}}</strong></h5>
    <article>
        <p style="height: 120px; font-size: 18px">
            {{item.ItemDescription}}
        </p>
    </article>
    <hr />

</div>
</div>
 <script type="text/ng-template" id="myModalContent">
<div class="modal-body">
    <h3>Title</h3>
    <img src="{{'data:image/jpg;base64,'+item.Image}}" style="height:150px; width:150px;">

</div>
<div class="modal-footer">

</div>

Controller

 $scope.currentItem = null;
$scope.getIceDesignImage = function (item) {
    $scope.currentItem = item;

    var modalInstance = $modal.open({
        templateUrl: 'myModalContent',
        controller: 'MainCtrl',
        resolve: {
            currentItem: function () {
                return $scope.currentItem;
            }
        }
    });

    modalInstance.result.then(function (selectedItem) {
        $scope.selected = selectedItem;
    }, function () {

    });
}

Answer №1

Although this information may be outdated, I want to clarify for anyone who comes across it (just as I did) that the img tag is incorrect. The correct format should be as follows:

<img src="data:image/jpg;base64,{{item.Image}}" style="height:150px; width:150px;">

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Adjusting Bootstrap buttons to have a margin-left of -1px when clicked outside the designated area

I utilized Bootstrap in my project, implementing the following code: <div class="input-group"> <input type="text" class="form-control input-lg" autofocus> <span class="input-group-btn"> <button class="btn btn-primary btn-lg" t ...

Java Entity Framework Indexing Tables

I am currently utilizing ASP.Net Core and have implemented EntityFramework to create a controller with views. Specifically, I am in the process of enhancing the Index view to make it dynamic with dropdown selections. I have successfully completed everythin ...

Interconnected directives, inheriting scope, and monitoring data flow from parent to child

I'm struggling to configure a couple of directives with a parent/child hierarchy and I'm facing some challenges in understanding how scope is managed within nested directives. My goal is for a child directive to react to changes in a parent direc ...

Error: Unable to simplify version range

Attempting to follow the Express beginner's guide. I created an app and executed npm install as per the provided instructions. > npx express-generator --view=pug myapp > npm install npm ERR! semver.simplifyRange is not a function npm ERR! A com ...

Guide on setting up a MEAN stack application to run on port 8080

I am brand new to the mean stack development environment. I'm attempting to configure my root domain name to display the app directory once I enter the command grunt, but the only way it currently works is at website.com:8080/!#/. How can I get it to ...

Guide to including a promise.map (bluebird) within a nested promise chain

I'm currently using a chain to control flow and struggling to make promise.map within step2() wait for all generated promises to be resolved. Here's a visual representation of the flow I aim for: step1() step2() step2() ste ...

Ways to prevent the TAB key from automatically shifting focus to the next element after using scrollIntoView during page initialization in the Chrome browser

Encountering a strange issue specifically on the Chrome browser. After the page loads, I am using the scrollIntoView method in the ngAfterViewInit of an Angular component. When the page loads and scrolls to the element, everything appears to be functioning ...

I simply aim to remove a single piece of news at a time, yet somehow I manage to delete more than intended

Do you have a PHP file containing a list of news items fetched from the database? Each news item has a delete link, which looks like this: echo '<a id="'.$result_news['id_news'].'" class="j_newsdelete" href="#">Delete</a ...

Use ng-repeat to dynamically calculate the sum of values in a textbox in AngularJS

Greetings everyone! I am currently utilizing AngularJS and I am attempting to sum the values that are entered in an ng-repeat text box, row by row. However, my current solution sums up all the data instead of doing it row by row. Can anyone offer guidance ...

Sending data to server using Ajax and jQuery

Hey there, experiencing a little hiccup in the back-end of my system when I try to submit my form. It keeps showing me an error saying Unidentified index: file1 . Can't seem to pinpoint where the issue lies in my code. Even though I'm no beginner ...

User currently signed in: What specific information should be transmitted to the web browser?

Experience: Currently utilizing the MEAN stack for a web application and still in the learning process. The Concern: I am facing some confusion regarding a particular aspect. For instance, if a user is logged in (using Passport.js), I can access their inf ...

Using a promise instead of resolving it with Angular's $q.then() methodology

Imagine you come across the given code snippet: var callNo1 = $http(...).then(function (response1) { var callNo2 = $http(...).then(function (response2) { return [response1.data, response2.data]; }); return callNo2; }).then(function (r ...

Identifying Inaccurate Device Date Using JavaScript

Is there a way to detect if the device's date is inaccurate using javascript? (For example, displaying an alert if the current date is 2016/6/16 but the device date is 2016/6/15) ...

Error: SyntaxError - Unexpected token 'if' found. Additionally, ReferenceError - berechnung is not defined

I keep encountering two error messages and I'm not sure where the issue lies: Uncaught SyntaxError: Unexpected token 'if' Uncaught ReferenceError: berechnung is not defined Any idea what might be causing this problem? I've reviewed t ...

Error message: Unable to locate module when using a variable to import an image in React

I've encountered an issue with my React code that I can't seem to figure out. I am integrating the Accuweather API and trying to display the weather icon on my app. Initially, everything seemed to be working fine as I constructed the image path l ...

What is the best way to retrieve the dimensions of a custom pop-up window from the user?

Currently, I am in the process of developing a website that allows users to input width and height parameters within an HTML file. The idea is to use JavaScript to take these user inputs and generate a pop-up window of a custom size based on the values pro ...

Is there a way to trigger an animation after the completion of ng-repeat binding?

Check out this plunker that demonstrates an interesting behavior: the class ng-hide is removed from a tag before ng-repeat has finished creating the HTML view of the data. This results in the height of the element not being final when removeClass is trigge ...

Tips for retrieving the text enclosed within a <span> tag using jQuery

I am new to jQuery and came across this code online for a questionnaire. I want to save the selected options but I am not sure how to do it. " $.fn.jRadio = function (settings)" What is the purpose of this setting? " var options = $.extend(_de ...

Combine Firebase and Stamplay services to leverage the power of Firebase Authorization in conjunction with Stamplay's Stripe integration

After successfully developing an App with Firebase as the backend, my next step is to implement Stripe for charging users and sending payments (or PayPal if it's a suitable alternative). Delving into solutions online, I've discovered that most of ...

Is Node.js or Express.js a server-side language like PHP or something completely different?

Hello, I have a question about Node.js and Express.js. I come from a PHP background and understand that PHP operations and functions execute on the server and return results to the client's screen. In simple terms, does Node.js/Express.js serve the s ...