Generating html css source code in angular javascript or something else

I am creating an HTML layout drag and drop mechanism using Angular.js. Now I want to save the generated HTML, CSS source code, removing Angular.js code only from the project. Is this their solution for generating HTML, CSS code using Angular.js?

+6
source share
1 answer

Here you can use jquery to get your html like

var allContent = $('.page-content').clone(); 

Remove excess tag this way

 //remove all angular class allContent.find("div[class^='ng-'],div[class*='ng-']").each(function () { //check and remove class }); //remove all ng-model attribute ans so no allContent.find('*[ng-model]').removeAttr('ng-model'); 

Clear your html and get all the html

 allContent.htmlClean(); var customPageContent = allContent.html(); 

and finally save it using https://github.com/eligrey/FileSaver.js

 var blob = new Blob([customPageContent], { type: "application/xhtml+xml;charset=charset=utf-8" }); saveAs(blob, fileName + ".html"); 

Additional function

 //clear your html $.fn.htmlClean = function () { this.contents().filter(function () { if (this.nodeType != 3) { $(this).htmlClean(); return false; } else { this.textContent = $.trim(this.textContent); return !/\S/.test(this.nodeValue); } }).remove(); return this; }; 

I think this will help you.

+1
source

Source: https://habr.com/ru/post/985012/


All Articles