Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

136
Vistas
How to read local Storage JSON in angular index.html file and show in View page source as a script

I have JSON in my localStorage which I want to read in my angular index.html file and also I want to show this JSON when I see the View page source. Below code, I have tried. Note: When I am seeing View page source then only Plain HTML is showing noting dynamic from localStorage.

<html>
<body>
<script type="text/javascript">
    window.onload = function() {
      alert(JSON.stringify(JSON.parse(localStorage.getItem('profileJson'))));
      var data = JSON.stringify(JSON.parse(localStorage.getItem('profileJson')))
      var nameFromJson = data.default.provider.name
      document.getElementById("demo").innerHTML = nameFromJson;

    }
  </script>
  <p id="demo"></p>

  <app-root></app-root> 

</body>
</html>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

View page source only gets the raw HTML then displays it. Therefore, you wouldn't be able to access the local storage when you're getting that text out because it would require JavaScript to be run.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda