extracting or converting angular js page to static html page - javascript

I have tabbed angularjs application, is it possible to get the html page out of my current page which has the model variables.
so for example i have table
<td>book.name<td>
It displays the value but the view source has only this book.name. is there a angular function to get this static html view?
so I will get
<td>.Net<td>
Edit: Trying to convert the html into OpenXML. Use it later to convert to different office documents. leave out certain parts add some parts etc would be easier that way in OpenXML format

Related

(Reactjs) Persist html file with styling to database

I am working on a React app which allows users to drag and drop UI elements to generate a template. At the end of the process, we have an HTML preview of the template displayed to the user.
What would be the best way to save this HTML (along with the styling) to the server ? A few approaches we tried:
Convert HTML to string and persist. This makes it difficult to import these templates at a later point in time (and extract the react components out of it)
Store all the HTML and styling data in some JSON format. But there is just too much to store (all the margins, padding values etc.)
Any ideas?
EDIT : The reason I am asking this is because there might be a totally different way of storing templates server side which I might be unaware of. For example, we currently store .docx files as templates. They provide an easy way of representing (and visualising) all the styling info of the document. And it is convenient to just save the docx file, than to parse through the HTML and extract all the styling info into a JSON. Now we are doing away with .docx because of some business limitations.

How can I get the rendered output of a View as a string with the javascript executed

I am using ASP.Net MVC5.
I need to create a PDF of a View which contains a c3.js chart.
As the chart is rendered an created through javascript (it creates an svg).
I tried to get the View output mentioned in:
Render a view as a string
But I just get the initial HTML of the View with the CSS styling.
I need the javascript to be executed before creating the PDF.
Please let me know if anybody has faced such a situation.
Or it also would be helpful to suggest any javascript library where I can get a specific as a pdf (without a server trip).
Thanks.

How to get content from a dynamic webpage

recently, I am developing an iOS app that want to get the content from a dynamic webpage.
Here is what I want to do:
http://www.ratemycoopjob.com
For the website above, I want to get ratings for employers I searched. The question is this page is a dynamic page, some javascript code will be called once search. I cannot treat this page as a static html file and parse it.
To parse an HTML in iOS, you could try HtmlParser of Ben Reeves (https://github.com/zootreeves/Objective-C-HMTL-Parser)
But first, you have to collect data from that site, generally by using REST service: POST/GET with right parameters or having the APIs
Edit: sorry, I did not read carefully your question. In case of JS, you can create an UIWebView, load this site into that view, then use
NSString *returnvalue = [webView stringByEvaluatingJavaScriptFromString:#"your javascript code string here"];
to get new content after affected a javascript on this site. However, you have to know about java script function of that site.
Good lucks

AngularJS: Render HTML output to a string

I am writing an app that must generate a PDF file based on the HTML generated by AngularJS. I do not want to display this output to the user. I want to capture the rendered HTML to a string and send it to a server, where a service there will receive the HTML source and create the PDF file.
I understand that one way to grab rendered HTML is through accessing the element's innerHTML property after compiling it in a directive. But how can I be certain that there are no further digests that need to take place? Also, can this method work without writing the results to the DOM? -- Or, at least, without displaying the results to the user? Thanks!

What is the best approach for handling a complex form in html?

I need to implement a webform (JSP, struts) featuring loads of checkboxes and textfields. Basically I have a tree made of checkboxes which has to be extendable (like adding a new node). On another page the same data is used, but refined. So you add again child nodes to the mentioned data structure using textboxes etc. I can describe the datastructure in XML:
But contains about 100 rows in reality.
I found 3 approaches:
1. Do a webform in JSP which lowers the user experience because lots of postbacks are necessary (every time i add/edit/delete a node, subnode...)
2. do it in async fashion. -> loads of javascript to handle the structure of the data (keep the XML data in a hidden div and update ui)
3. go for a RIA like OpenLaszlo
What do you suggest?
If you already know OpenLaszlo, go for it. You will end up with a better user experience with less work.
You should target user interface and performance when developing an app. So IMO, plain JSP will be my last approach.
You can consider client side rendering.It allows to build very responsive web apps:
build your JSP pages to deliver JSON data, no HTML here
use a javascript templating engine in the browser to convert the data in HTML client side. I'm the author of PURE but there are plenty of others on the web that may suit better your style
when the user types or press submit, parse the form using a common technique found in many frameworks. i.e: the "name" attribute is the path to set the value in the JSON<input name="employee.name" type="text" ... />
When the form is parsed, post back the JSON to a JSP page that will read it and do the backend work.
You can use XML instead of JSON and XSLT instead of a JS templating engine, but if you target the web browser only, it adds an extra layer of complexity and trouble to parse the XML.

Categories