🎨 Added more components.

And even a working get request to the API.
This commit is contained in:
corner 2019-09-21 15:44:03 +02:00
parent e620e01037
commit de242382a7
13 changed files with 108 additions and 23 deletions

View File

@ -1,7 +1,16 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './components/home/home.component';
import { ArtistsComponent } from './components/artists/artists.component';
import { AlbumsComponent } from './components/albums/albums.component';
const routes: Routes = [];
const routes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'artists/:id', component: ArtistsComponent },
{ path: 'artists/', component: ArtistsComponent },
{ path: 'albums/:id', component: AlbumsComponent },
{ path: 'albums/', component: AlbumsComponent }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],

View File

@ -1,21 +1,5 @@
<!--The content below is only a placeholder and can be replaced.-->
<div style="text-align:center">
<h1>
Welcome to {{ title }}!
</h1>
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
</div>
<h2>Here are some links to help you start: </h2>
<ul>
<li>
<h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2>
</li>
<li>
<h2><a target="_blank" rel="noopener" href="https://angular.io/cli">CLI Documentation</a></h2>
</li>
<li>
<h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2>
</li>
</ul>
<app-nav></app-nav>
<router-outlet></router-outlet>
<app-controls></app-controls>

View File

@ -9,6 +9,8 @@ import { HomeComponent } from './components/home/home.component';
import { SongComponent } from './components/song/song.component';
import { ArtistsComponent } from './components/artists/artists.component';
import { AlbumsComponent } from './components/albums/albums.component';
import { NavComponent } from './components/nav/nav.component';
import { ControlsComponent } from './components/controls/controls.component';
@NgModule({
declarations: [
@ -16,7 +18,9 @@ import { AlbumsComponent } from './components/albums/albums.component';
HomeComponent,
SongComponent,
ArtistsComponent,
AlbumsComponent
AlbumsComponent,
NavComponent,
ControlsComponent
],
imports: [
BrowserModule,

View File

@ -0,0 +1 @@
<p>controls works!</p>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ControlsComponent } from './controls.component';
describe('ControlsComponent', () => {
let component: ControlsComponent;
let fixture: ComponentFixture<ControlsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ControlsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ControlsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-controls',
templateUrl: './controls.component.html',
styleUrls: ['./controls.component.scss']
})
export class ControlsComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}

View File

@ -1 +1 @@
<p>home works!</p>
<p>{{ (song | async) | json }}</p>

View File

@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { DataService } from 'src/app/services/data.service';
import { Observable } from 'rxjs';
@Component({
selector: 'app-home',
@ -7,9 +9,13 @@ import { Component, OnInit } from '@angular/core';
})
export class HomeComponent implements OnInit {
constructor() { }
song: Observable<object>;
constructor(private data: DataService) { }
ngOnInit() {
// Load the first song from the API
this.song = this.data.getSong(0);
}
}

View File

@ -0,0 +1 @@
<p>nav works!</p>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NavComponent } from './nav.component';
describe('NavComponent', () => {
let component: NavComponent;
let fixture: ComponentFixture<NavComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ NavComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(NavComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-nav',
templateUrl: './nav.component.html',
styleUrls: ['./nav.component.scss']
})
export class NavComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}