Commit 5a2a2301706893d12f70133348f076c1cef732c4
1 parent
ccb3f7c1f5
Exists in
master
obtengo nombre de la empresa
Showing
2 changed files
with
27 additions
and
4 deletions
Show diff stats
src/app/nombre-empresa/nombre-empresa.component.html
1 | <div class="container"> | 1 | <div class="container"> |
2 | <div class="row align-items-end"> | 2 | <div class="row align-items-end"> |
3 | <div class="col-md-6"> | 3 | <div class="col-md-6"> |
4 | <h5 class="text-left"><strong>Demo distribuidor</strong></h5> | 4 | <h5 class="text-left"><strong>{{nombreEmpresa}}</strong></h5> |
5 | </div> | 5 | </div> |
6 | <div class="col-md-6"> | 6 | <div class="col-md-6"> |
7 | <h5 class="text-right align-bottom"><small>Paso de los andes 1874</small></h5> | 7 | <h5 class="text-right align-bottom"><small>{{direccionEmpresa}}</small></h5> |
8 | </div> | 8 | </div> |
9 | </div> | 9 | </div> |
10 | </div> | 10 | </div> |
11 | 11 |
src/app/nombre-empresa/nombre-empresa.component.ts
1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
2 | import { NombreEmpresaService } from './nombre-empresa.service'; | ||
2 | 3 | ||
3 | @Component({ | 4 | @Component({ |
4 | selector: 'app-nombre-empresa', | 5 | selector: 'app-nombre-empresa', |
5 | templateUrl: './nombre-empresa.component.html', | 6 | templateUrl: './nombre-empresa.component.html', |
6 | styleUrls: ['./nombre-empresa.component.css'] | 7 | styleUrls: ['./nombre-empresa.component.css'], |
8 | providers: [NombreEmpresaService] | ||
7 | }) | 9 | }) |
8 | export class NombreEmpresaComponent implements OnInit { | 10 | export class NombreEmpresaComponent implements OnInit { |
9 | 11 | ||
10 | constructor() { } | 12 | nombreEmpresa: string; |
13 | direccionEmpresa: string; | ||
14 | |||
15 | constructor(private nombreEmpresaService: NombreEmpresaService) { } | ||
11 | 16 | ||
12 | ngOnInit() { | 17 | ngOnInit() { |
18 | |||
19 | if (localStorage.getItem('nombreEmpresa') && localStorage.getItem('direccionEmpresa')) { | ||
20 | this.nombreEmpresa = localStorage.getItem('nombreEmpresa'); | ||
21 | this.direccionEmpresa = localStorage.getItem('direccionEmpresa'); | ||
22 | } else { | ||
23 | |||
24 | this.nombreEmpresaService | ||
25 | .getNombreEmpresa() | ||
26 | .subscribe(data => { | ||
27 | |||
28 | this.nombreEmpresa = data['nombreEmpresa']; | ||
29 | this.direccionEmpresa = data['direccionEmpresa']; | ||
30 | |||
31 | localStorage.setItem('nombreEmpresa', this.nombreEmpresa); | ||
32 | localStorage.setItem('direccionEmpresa', this.direccionEmpresa); | ||
33 | }, err => console.log(err) ); | ||
34 | } | ||
35 | |||
13 | } | 36 | } |
14 | 37 | ||
15 | } | 38 | } |
16 | 39 |