Leveraging AngularJS for creating PDF elements

I've been working with an angular controller that pulls json data from my server and displays it dynamically. Here's the code snippet for showing images:

    <div ng-controller="myImgController">
      <div ng-repeat="img in imgs">
        <div ng-repeat="i in img">
          <img ng-src="{{i.id}}"/>
        </div>
      </div>
    </div>

Now, my challenge is to generate markup dynamically to display PDFs within the browser using a similar approach. This is what I have so far:

    <div ng-controller="myNewPdfController">
      <div ng-repeat="pdf in pdfs">
        <div ng-repeat="p in pdf">
          <object ng-attr-data="{{p.id}}" type="application/pdf" width="100%" height="100%"></object>
        </div>
      </div>
    </div>

I'm facing issues with ng-attr-data / ng-src not properly updating the PDF source. Just to clarify, the p.id contains the URL of the PDF file.

If anyone has a solution or suggestions to tackle this problem effectively, please feel free to share. There are various resources available, but I wanted to present a clear question for others facing a similar issue.

Answer №1

Following the guidance of Captain, I delved into researching Directives and ultimately utilized them to achieve a functional solution. The process entailed implementing multiple ng-repeats, sending a request to the server, and using a directive for generating PDF objects. Feel free to reach out if you require further clarification. This brief summary signifies that the question has been successfully addressed.

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

Navigating between routes in NEXT JS involves passing state, which can be achieved through various

Within one of my page objects, I have some data that I need to send to another page when redirecting. The code snippet below shows how I achieved this: const redirectAppointmentStep1 = (value) => { router.push({ pathname: '/Appointment/bo ...

What is the best way to store the JSON data that is returned in a JavaScript function as a variable

My goal is to save the client's IP address in a variable after fetching it in JSON format from api.ipify.org. I have managed to display the IP if I alert the result, but I am struggling to store it in a variable. This code snippet works: <script& ...

The JSON data is empty once it has been decoded

Hey everyone, I have a question regarding handling API responses. Whenever I make an API call, I receive a response containing various details. I then pass this response to a method like this: completionHandler(response: response, error: nil) Afterwards, ...

Storing User Information in Discord.js to Prevent Spam

I'm currently working on creating an anti-spam feature using Discord.js. However, I am facing a challenge in saving data such as the timestamp of the user's last message sent. ...

Issues encountered with making JSONP requests

Hey there, I'm a bit stuck and need some help figuring out what's going wrong. Sometimes a fresh perspective can make all the difference. So, here's the situation: I'm making a JSONP request using jQuery from one domain () to a PHP scri ...

Addressing a critical issue: Unhandled exception from pcrovJsonReaderParserParseException (php json)

Utilizing a JSON parser specifically designed for PHP 7 to retrieve information from a substantial 25GB json file. Here is the link to the sample json file. Data extraction process runs smoothly until it encounters Line 153731 in the json file, leading t ...

The conversion from CSV to JSON using the parse function results in an inaccurate

I am having trouble converting a CSV file to JSON format. Even though I try to convert it, the resulting JSON is not valid. Here is an example of my CSV data: "timestamp","firstName","lastName","range","sName","location" "2019/03/08 12:53:47 pm GMT-4","H ...

Incorporate JavaScript to enable the transfer of text from one textarea to another upon clicking a button, while simultaneously clearing the original textarea

After working on the provided code, I have managed to create a functionality where text from one textarea is copied to another textarea when a button is clicked using JavaScript. <head> <script type="text/javascript"> function displayOut(){ ...

Theme not being rendered properly following the generation of a dynamic component in Angular

I am currently working on an Angular 9 application and I have successfully implemented a print functionality by creating components dynamically. However, I have encountered an issue where the CSS properties defined in the print-report.component.scss file a ...

Protractor is having difficulty initializing a webdriver session

Can someone please assist me with this issue? Hello there! I'm having trouble running a protractor test as Chrome is only displaying a blank page. The error message indicates that the WebDriver could not be started. ✗ protractor config.js --trou ...

Please incorporate the href attribute into the anchor tag when it is clicked

<section> <a **id="download"** oncontextmenu="return false" > <svg ... </svg></a> </section> <script type="text/javascript"> The following code snippet is designed to ...

Issues in the d3.js chart

I'm facing an issue with some incorrect lines appearing in my d3.js chart. Strangely, the problem seems to disappear when I switch tabs on Chrome and return to the chart's tab. It's puzzling to figure out the root cause of this issue, so I ...

Exploring the versatility of orderBy and filter in handling cross-referenced content across multiple JSON objects

Is there a way to filter and search for the item name when the item details are sourced from another JSON object? Demo: http://codepen.io/anon/pen/GjAxKX While the rest of the filtering and ordering functionalities are functioning correctly, I am struggl ...

Can you explain the difference between dots-per-CSS-inch and dots-per-physical-inch?

When accessing jsfiddle.net, I received the following message in the Chrome Developer Tools console tab: The message suggests using 'dppx' units instead of 'dpi' in CSS, as 'dpi' does not correspond to the actual screen den ...

Dealing with redirect issues in a React-Material menu: A guide to troubleshooting and

When working with my menu, I face a variety of issues. First and foremost, within the initial RETURN section, there is a TREEITEM with a LISTITEM and a LISTITETEXT. I have included an OnClick event in the LISTITETEXT so that if the menu's id matches ...

Obtaining the value of a JSON object is not defined - utilizing jQuery's

It has been quite some time since I last dabbled in jQuery and I am currently facing a challenge extracting the value from the JSON returned by the server. C# approach [HttpGet] public JsonResult AjaxGetSingleNewsItem(int Id) { ...

URL-based Angular Material Autocomplete feature

I have achieved what I expected, but there seems to be an issue with how the data is being loaded. Every time I input new letters, all JSON data is read again. What I want is to load the JSON through an HTTP request and apply filters directly on the pre-lo ...

Toggle a jQuery bar based on the presence of a specific CSS class

I am working on a feature where I can select and deselect images by clicking on a delete button. When an image is selected, a bar appears at the top. If I click the same delete button again, the image should be deselected and the bar should disappear. This ...

The Datatable feature is malfunctioning, unable to function properly with Javascript and JQuery

As a novice in the world of jquery/javascript, I find myself struggling with what may seem like an obvious issue. Despite following tutorials closely (the code for the problematic section can be found at jsfiddle.net/wqbd6qeL), I am unable to get it to wor ...

The registration form's captcha did not prevent the submission of incorrect captchas

This is a PHP register.php page <?php require_once 'config.php'; ?> <?php if(!empty($_POST)){ try { $user_obj = new Cl_User(); $data = $user_obj->registration( $_POST ); if($data)$succ ...