Commit fef86573 by Luciano Barletta

forms added, search added

1 parent 0bc7ec18
...@@ -7,7 +7,7 @@ import { BusquedaComponent } from './busqueda/busqueda.component'; ...@@ -7,7 +7,7 @@ import { BusquedaComponent } from './busqueda/busqueda.component';
const routes: Routes = [ const routes: Routes = [
{ path: '', component : MainComponent }, { path: '', component : MainComponent },
{ path: 'informacion/:id', component: InformacionComponent }, { path: 'informacion/:id', component: InformacionComponent },
{ path: 'busqueda', component: BusquedaComponent } { path: 'busqueda/:search', component: BusquedaComponent }
]; ];
/* { path: '**', component: PageNotFoundComponent } */ /* { path: '**', component: PageNotFoundComponent } */
......
...@@ -9,6 +9,7 @@ import { NavBarComponent } from './nav-bar/nav-bar.component'; ...@@ -9,6 +9,7 @@ import { NavBarComponent } from './nav-bar/nav-bar.component';
import { InformacionComponent } from './informacion/informacion.component'; import { InformacionComponent } from './informacion/informacion.component';
import { ImagesService } from './services/images.service'; import { ImagesService } from './services/images.service';
import { BusquedaComponent } from './busqueda/busqueda.component'; import { BusquedaComponent } from './busqueda/busqueda.component';
import { FormsModule } from '@angular/forms';
@NgModule({ @NgModule({
declarations: [ declarations: [
...@@ -21,7 +22,8 @@ import { BusquedaComponent } from './busqueda/busqueda.component'; ...@@ -21,7 +22,8 @@ import { BusquedaComponent } from './busqueda/busqueda.component';
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
AppRoutingModule AppRoutingModule,
FormsModule
], ],
providers: [ImagesService], providers: [ImagesService],
bootstrap: [AppComponent] bootstrap: [AppComponent]
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, ParamMap } from '@angular/router';
@Component({ @Component({
selector: 'app-busqueda', selector: 'app-busqueda',
...@@ -7,12 +8,18 @@ import { Component, OnInit } from '@angular/core'; ...@@ -7,12 +8,18 @@ import { Component, OnInit } from '@angular/core';
}) })
export class BusquedaComponent implements OnInit { export class BusquedaComponent implements OnInit {
search : string;
order : string = "Asc"; order : string = "Asc";
results : any[]; results : any[];
constructor() { } constructor(private route : ActivatedRoute) { }
ngOnInit(): void { ngOnInit(): void {
this.route.paramMap.subscribe(
(params) => this.search = params.get('search')
);
this.results = [ this.results = [
"cosa1", "cosa1",
"cosa2", "cosa2",
...@@ -25,6 +32,6 @@ export class BusquedaComponent implements OnInit { ...@@ -25,6 +32,6 @@ export class BusquedaComponent implements OnInit {
} }
change() { change() {
this.order == "Asc" ? "Des" : "Asc"; this.order = (this.order == "Asc" ? "Des" : "Asc");
} }
} }
...@@ -38,3 +38,14 @@ ...@@ -38,3 +38,14 @@
border-radius: 10px; border-radius: 10px;
} }
.NavSuggestion {
background-color: white;
border: solid 1px grey;
position: absolute;
width: 30%;
left: 70%;
padding: 3px;
top: 0;
transform: translate(-50%,220%);
}
...@@ -6,10 +6,13 @@ ...@@ -6,10 +6,13 @@
<img class="NavLogo" src="assets/images/LogoProv2.png" style="height: auto; width: 250px;"> <img class="NavLogo" src="assets/images/LogoProv2.png" style="height: auto; width: 250px;">
</a> </a>
<div class="NavSearchContainer"> <div class="NavSearchContainer">
<input class="NavInput" type="text" placeholder="Search.."> <input [(ngModel)]="search" (keyup)="showinput()" (keydown)="hideinput()" class="NavInput" type="text" placeholder="Search..">
<a routerLink="/busqueda"> <a routerLink="/busqueda/{{ search }}">
<i class="fas fa-search fa-2x" style="color:white;"></i> <i class="fas fa-search fa-2x" style="color:white;"></i>
</a> </a>
<div *ngIf="suggestion" class="NavSuggestion">
<i>buscar {{ search }}</i>
</div>
</div> </div>
<a href="javascript:" routerLink="/"> <a href="javascript:" routerLink="/">
<i class="fas fa-user-circle fa-3x" style="color:white;"></i> <i class="fas fa-user-circle fa-3x" style="color:white;"></i>
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Observable, interval } from 'rxjs';
import { switchMap, take } from 'rxjs/operators';
@Component({ @Component({
selector: 'nav-bar', selector: 'nav-bar',
templateUrl: './nav-bar.component.html', templateUrl: './nav-bar.component.html',
styleUrls: ['./nav-bar.component.css'] styleUrls: ['./nav-bar.component.css']
}) })
export class NavBarComponent implements OnInit { export class NavBarComponent implements OnInit {
constructor() { } search : string = '';
suggestion : boolean = false;
ngOnInit(): void { constructor() { }
}
ngOnInit(): void {
}
showinput() {
interval(1000).pipe( take(1) )
.subscribe(
() => this.suggestion = true
);
}
hideinput() {
this.suggestion = false;
}
} }
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!