Skip to content

Commit 93ea1bf

Browse files
refactor: remove nav title behaviorsubject
1 parent e0e8f8a commit 93ea1bf

File tree

8 files changed

+3
-41
lines changed

8 files changed

+3
-41
lines changed

src/app/movie/add-movie/add-movie.component.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { MovieService } from "./../services/movie.service";
2-
import { NavbarService } from "./../../navbar/services/navbar.service";
32
import { Component, OnInit } from "@angular/core";
43
import { UntypedFormGroup, UntypedFormControl, Validators } from "@angular/forms";
54
import { Router } from "@angular/router";
@@ -20,11 +19,9 @@ export class AddMovieComponent implements OnInit {
2019
constructor(
2120
private router: Router,
2221
private movieService: MovieService,
23-
private navbarService: NavbarService
2422
) {}
2523

2624
ngOnInit() {
27-
this.navbarService.title.next("Add Movies");
2825
}
2926

3027
addMovie() {

src/app/movie/movie-detail/movie-detail.component.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { NavbarService } from "./../../navbar/services/navbar.service";
21
import { MovieService } from "./../services/movie.service";
32
import { Component, OnInit, OnDestroy } from "@angular/core";
43
import { ActivatedRoute } from "@angular/router";
@@ -17,7 +16,6 @@ export class MovieDetailComponent implements OnInit, OnDestroy {
1716

1817
constructor(
1918
private movieService: MovieService,
20-
private navbarService: NavbarService,
2119
private route: ActivatedRoute
2220
) {}
2321

@@ -27,7 +25,6 @@ export class MovieDetailComponent implements OnInit, OnDestroy {
2725
.movieFromHttp(this.id)
2826
.subscribe((movie) => {
2927
this.movie = movie;
30-
this.navbarService.title.next(movie.name);
3128
});
3229
}
3330

src/app/movie/movie-list/movie-list.component.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Component, OnInit } from "@angular/core";
22
import { Observable } from "rxjs";
3-
import { NavbarService } from "./../../navbar/services/navbar.service";
43
import { Movie } from "../models/movie.model";
54
import { MovieService } from "./../services/movie.service";
65
import {
@@ -50,14 +49,12 @@ export class MovieListComponent implements OnInit {
5049

5150
// inject movie & navbar services
5251
constructor(
53-
private movieService: MovieService,
54-
private navbarService: NavbarService
52+
private movieService: MovieService
5553
) {}
5654

5755
ngOnInit() {
5856
this.loadingMovies = new Array(9).fill(0).map((n, index) => index);
5957

6058
this.movies$ = this.movieService.getMoviesFromHttp();
61-
this.navbarService.title.next("FilmSelector");
6259
}
6360
}

src/app/movie/movie/movie.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div>
1+
<div *ngIf="movie">
22
<img [src]="movie.image">
33
<h1>{{movie.id}} - {{movie.name}}</h1>
44
<h2>{{movie.genre}} - {{movie.releaseYear}}</h2>

src/app/navbar/navbar.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<nav>
2-
<h1 routerLink="/">{{ title$ | async }}</h1>
32
<button routerLink="movies/add" *ngIf="!router.url.includes('movies/add')">
43
Add
54
</button>

src/app/navbar/navbar.component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { NavbarService } from "./services/navbar.service";
21
import { Component, OnInit } from "@angular/core";
32
import { Router } from "@angular/router";
43

@@ -8,9 +7,8 @@ import { Router } from "@angular/router";
87
styleUrls: ["./navbar.component.scss"],
98
})
109
export class NavbarComponent implements OnInit {
11-
title$ = this.navbarService.title;
1210

13-
constructor(public navbarService: NavbarService, public router: Router) {}
11+
constructor(public router: Router) {}
1412

1513
ngOnInit() {}
1614
}

src/app/navbar/services/navbar.service.spec.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/app/navbar/services/navbar.service.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)