diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 0297262..dbcf789 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -1,10 +1,37 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
+import { TablaComponent } from './rick/pages/tabla/tabla.component';
-const routes: Routes = [];
+
+const routes: Routes = [
+ {
+ path: '',
+ component: TablaComponent,
+ pathMatch: 'full'
+ },
+
+ /* {
+ path: 'buscar',
+ component:
+ },
+ {
+ path: 'ordenar',
+ component:
+ }, */
+ {
+ path: '**',
+ redirectTo: ''
+ }
+
+
+];
@NgModule({
- imports: [RouterModule.forRoot(routes)],
- exports: [RouterModule]
+ imports: [
+ RouterModule.forRoot(routes)
+ ],
+ exports: [
+ RouterModule
+ ]
})
export class AppRoutingModule { }
diff --git a/src/app/app.component.css b/src/app/app.component.css
index e69de29..8b57b00 100644
--- a/src/app/app.component.css
+++ b/src/app/app.component.css
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/src/app/app.component.html b/src/app/app.component.html
index 139597f..c9d1423 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -1,2 +1,4 @@
+
+
\ No newline at end of file
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 8dc32c0..c5605c3 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -1,10 +1,15 @@
import { Component } from '@angular/core';
+import { MatPaginatorIntl } from '@angular/material/paginator';
+import { MatTableDataSource } from '@angular/material/table';
+import { Subject } from 'rxjs';
+
+
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
-export class AppComponent {
+export class AppComponent {
title = 'rickandmortyApp';
}
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 8386405..3cf7e14 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -5,16 +5,26 @@ import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
+import { RickModule } from './rick/rick.module';
+import { MaterialModule } from './material/material.module';
+import { HttpClientModule } from '@angular/common/http';
+
+
@NgModule({
declarations: [
- AppComponent
+ AppComponent,
+
+
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
+ HttpClientModule,
+ MaterialModule,
+ RickModule
],
providers: [],
diff --git a/src/app/material/material.module.ts b/src/app/material/material.module.ts
new file mode 100644
index 0000000..6948e4f
--- /dev/null
+++ b/src/app/material/material.module.ts
@@ -0,0 +1,44 @@
+import { NgModule } from '@angular/core';
+
+import {MatCardModule} from '@angular/material/card';
+import { MatIconModule } from '@angular/material/icon';
+import {MatListModule} from '@angular/material/list';
+import {CdkTableModule} from '@angular/cdk/table';
+
+
+
+import { MatSidenavModule } from '@angular/material/sidenav';
+import {MatPaginatorModule} from '@angular/material/paginator';
+import {MatTableModule} from '@angular/material/table';
+import { MatToolbarModule } from '@angular/material/toolbar';
+
+
+
+@NgModule({
+ declarations: [],
+
+ exports:[
+ MatCardModule,
+ CdkTableModule,
+ MatIconModule,
+ MatListModule,
+
+ MatSidenavModule,
+ MatPaginatorModule,
+ MatTableModule,
+ MatToolbarModule
+
+ ],
+ imports:[
+ MatCardModule,
+ CdkTableModule,
+ MatIconModule,
+ MatListModule,
+
+ MatSidenavModule,
+ MatPaginatorModule,
+ MatTableModule,
+ MatToolbarModule
+ ]
+})
+export class MaterialModule { }
diff --git a/src/app/rick/interfaces/rick.interfaces.ts b/src/app/rick/interfaces/rick.interfaces.ts
new file mode 100644
index 0000000..9060e8f
--- /dev/null
+++ b/src/app/rick/interfaces/rick.interfaces.ts
@@ -0,0 +1,53 @@
+export interface Rickmorty {
+ info: Info;
+ results: Result[];
+}
+
+export interface Info {
+ count: number;
+ pages: number;
+ next: string;
+ prev: null;
+}
+
+export interface Result {
+ id: number;
+ name: string;
+ status: string | Status;
+ species?: Species;
+ type?: Type;
+ gender: string |Gender;
+ origin?: Location;
+ location?: Location;
+ image?: string;
+ episode?: string[];
+ url?: string;
+ created?: Date;
+}
+
+export enum Gender {
+ Female = "Female",
+ Male = "Male",
+}
+
+export interface Location {
+ name: string;
+ url: string;
+}
+
+export enum Species {
+ Alien = "Alien",
+ Human = "Human",
+ Unknown = "unknown",
+}
+
+export enum Status {
+ Alive = "Alive",
+}
+
+export enum Type {
+ Chair = "Chair",
+ Clone = "Clone",
+ Empty = "",
+ Pickle = "Pickle",
+}
diff --git a/src/app/rick/pages/tabla/tabla.component.css b/src/app/rick/pages/tabla/tabla.component.css
new file mode 100644
index 0000000..1ff7add
--- /dev/null
+++ b/src/app/rick/pages/tabla/tabla.component.css
@@ -0,0 +1,13 @@
+
+table {
+ width: 100%;
+}
+
+a {
+ cursor: pointer;
+}
+
+th{
+ width: 20%;
+}
+
diff --git a/src/app/rick/pages/tabla/tabla.component.html b/src/app/rick/pages/tabla/tabla.component.html
new file mode 100644
index 0000000..1273ab8
--- /dev/null
+++ b/src/app/rick/pages/tabla/tabla.component.html
@@ -0,0 +1,56 @@
+
+
+ Rick&MortyAPP
+
+
+
+
+
+
+
+
+
+ | No. |
+ {{element.id}} |
+
+
+
+
+ Nombre |
+ {{element.name}} |
+
+
+
+
+ Genero |
+ {{element.gender}} |
+
+
+
+
+ Tipo |
+ {{element.type}} |
+
+
+
+ Estatus |
+ {{element.status}} |
+
+
+
+ Ver más |
+
+
+ search
+
+ |
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/rick/pages/tabla/tabla.component.ts b/src/app/rick/pages/tabla/tabla.component.ts
new file mode 100644
index 0000000..e166141
--- /dev/null
+++ b/src/app/rick/pages/tabla/tabla.component.ts
@@ -0,0 +1,54 @@
+import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core';
+import { Rickmorty } from '../../interfaces/rick.interfaces';
+import { RickService } from '../../services/rick.service';
+import { MatTableDataSource } from '@angular/material/table';
+import { MatPaginator } from '@angular/material/paginator';
+
+
+
+
+@Component({
+ selector: 'app-tabla',
+ templateUrl: './tabla.component.html',
+ styleUrls: ['./tabla.component.css']
+})
+
+export class TablaComponent implements AfterViewInit, OnInit {
+
+ Columns: string[] = [ 'id', 'name', 'gender', 'type', 'status', 'ver' ];
+ dataSource = new MatTableDataSource;
+
+
+ constructor( private rickService: RickService ) { }
+
+ @ViewChild(MatPaginator) paginator!: MatPaginator;
+
+ ngAfterViewInit() {
+ this.dataSource.paginator = this.paginator;
+ }
+
+ cargaRick() {
+ this.rickService.getRick()
+ .subscribe( (res:any) =>{
+ console.log(res);
+ if (!res.info){
+ return console.log ('no info check data ');
+ }
+ else {
+ this.dataSource.data = res.results;
+ }
+ })
+ }
+
+ ngOnInit(): void {
+ this.cargaRick()
+
+
+ }
+}
+
+
+
+
+
+
diff --git a/src/app/rick/rick.module.ts b/src/app/rick/rick.module.ts
new file mode 100644
index 0000000..96f1629
--- /dev/null
+++ b/src/app/rick/rick.module.ts
@@ -0,0 +1,18 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+
+import { TablaComponent } from './pages/tabla/tabla.component';
+import { MaterialModule } from '../material/material.module';
+
+
+
+@NgModule({
+ declarations: [
+ TablaComponent,
+ ],
+ imports: [
+ CommonModule,
+ MaterialModule,
+ ]
+})
+export class RickModule { }
diff --git a/src/app/rick/services/rick.service.ts b/src/app/rick/services/rick.service.ts
new file mode 100644
index 0000000..725dd45
--- /dev/null
+++ b/src/app/rick/services/rick.service.ts
@@ -0,0 +1,22 @@
+import { Injectable } from '@angular/core';
+import { HttpClient } from '@angular/common/http';
+import { environment } from 'src/environments/environment';
+import { Observable } from 'rxjs';
+import { Rickmorty } from '../interfaces/rick.interfaces';
+
+
+
+@Injectable({
+ providedIn: 'root'
+})
+export class RickService {
+
+ private baseUrl: string = environment.baseUrl;
+
+
+ constructor(private http: HttpClient) { }
+
+ getRick() : Observable {
+ return this.http.get(`${this.baseUrl}`);
+ }
+}
diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts
index 3612073..f27c64f 100644
--- a/src/environments/environment.prod.ts
+++ b/src/environments/environment.prod.ts
@@ -1,3 +1,4 @@
export const environment = {
- production: true
+ production: true,
+ baseUrl: 'https://rickandmortyapi.com/api/character'
};
diff --git a/src/environments/environment.ts b/src/environments/environment.ts
index f56ff47..de02742 100644
--- a/src/environments/environment.ts
+++ b/src/environments/environment.ts
@@ -3,7 +3,8 @@
// The list of file replacements can be found in `angular.json`.
export const environment = {
- production: false
+ production: false,
+ baseUrl: 'https://rickandmortyapi.com/api/character'
};
/*