Created
September 17, 2017 16:55
-
-
Save rahulsahay19/140c5206d6958f8071b8f23b6429f1f8 to your computer and use it in GitHub Desktop.
movies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Component, | |
OnInit, | |
EventEmitter, | |
Output, | |
ViewEncapsulation, | |
ViewChild, | |
ElementRef, | |
DoCheck, | |
OnDestroy, | |
} from '@angular/core'; | |
import { Movie, MOVIES } from '../Models/Movie'; | |
import { Review, REVIEWS } from '../Models/Review'; | |
import { LoggingService } from '../logging.service'; | |
@Component({ | |
selector: 'app-movies', | |
templateUrl: './movies.component.html', | |
styleUrls: ['./movies.component.css'], | |
providers:[LoggingService] | |
}) | |
export class MoviesComponent implements OnInit, OnDestroy { | |
moviesColl = MOVIES; | |
reviewsColl = REVIEWS; | |
movies: Movie[] = []; | |
reviews: Review[] = []; | |
newMovieName = ''; | |
newDirectorName = ''; | |
newReleaseYear = ''; | |
newReviewerName = ''; | |
newComment = ''; | |
oddReviews =[1,3,5]; | |
evenNumbers=[2,4,6]; | |
onlyOdd=false; | |
@Output() movieCreated = new EventEmitter < Movie[] > (); | |
@Output() reviewCreated = new EventEmitter < Review[] > (); | |
@ViewChild('movieNameInput') movieNameInput: ElementRef; | |
constructor(private loggingService:LoggingService) {} | |
ngOnInit() { | |
} | |
onAddMovie(movieInput) { | |
this.movies.push({ | |
name: this.newMovieName, | |
directorName: this.newDirectorName, | |
releaseYear: this.newReleaseYear | |
}); | |
this.movieCreated.emit(this.movies); | |
} | |
onAddMovieReview() { | |
this.reviews.push({ | |
reviewer: this.newReviewerName, | |
comments: this.newComment | |
}); | |
this.reviewCreated.emit(this.reviews); | |
} | |
ngOnDestroy(){ | |
this.loggingService.logToConsole('ngOnDestroy called!'); | |
} | |
removeComponent(){ | |
this.reviewsColl.splice(0,1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment