Total Blog Views: 49
Blog Status: publish
Created By: asad_fazlani Created at: 08-22-2021
Tags: web development angular web app
In this blog i am going to develop movie app using angular.
create angular app , then generate service .
Api link given below,
url = 'https://api.themoviedb.org/3/search/movie?api_key=cdaa68790f7a7ae489aec9ad67eab53c&query=';
in your service.ts past this code,
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class RestService { | |
constructor(private http: HttpClient) { } | |
url = 'https://api.themoviedb.org/3/search/movie?api_key=cdaa68790f7a7ae489aec9ad67eab53c&query='; | |
data :string = 'avengers' | |
query :any | |
changedata(data) { | |
this.data = JSON.stringify(data.mname); | |
// this.data = "Avengers" | |
} | |
GetData() { | |
// console.log('url' + this.url + this.data); | |
return this.http.get(this.url + this.data) | |
} | |
} |
constructor(private http: RestService ,private route :Router) { } | |
loginForm = new FormGroup({ | |
mname: new FormControl('') | |
}); | |
ngOnInit() { | |
} | |
submit() { | |
this.http.changedata(this.loginForm.value); | |
} |
<form [formGroup] = "loginForm" >
<div id="input" class="md-form active-pink active-pink-2 mb-3 mt-0" >
<input class="form-control " type="text" placeholder="Enter Movie Name" formControlName="mname">
</div>
<button class="btn btn-outline-success active-pink active-pink-2 mb-3 mt-0 ml-3" routerLink="/result" (click) = "submit()">Submit</button>
</form>
form{margin: 0; padding: 0; height: 100vh; display: flex; align-items: center; justify-content: center; background: black;}#input{width: 40%; padding :20px} .btn{ width: 10%; }
constructor(private http: RestService) { }
data: any = []
results :any=[]
ngOnInit(): void
{ this.http.GetData().subscribe(
query => { this.data = query
// console.log(this.data.results);
this.submit();
});
}submit(){ this.results = this.data.results console.log(this.results); }
<h1 style="margin-left: 35%;">Search Results </h1>
<div class="card promoting-card" *ngFor = "let item of results" style="width :40% ;margin-left: 25%;margin-top: 2%;"><!-- Card content -->
<div class="card-body d-flex flex-row">
<!-- Avatar -->
<!-- <img src="https://mdbootstrap.com/img/Photos/Avatars/avatar-8.jpg" class="rounded-circle mr-3" height="50px" width="50px" alt="avatar"> -->
<!-- Content -->
<div>
<!-- Title -->
<h4 class="card-title font-weight-bold mb-2">{{item.original_title}}</h4>
<!-- Subtitle -->
<h5 class="mb-1"> vote_average : {{item.vote_average}}</h5>
</div>
</div>
<!-- Card image -->
<div class="view overlay">
<img class="card-img-top rounded-0"style="width :40%; height:50%; margin-left :20%" src="https://image.tmdb.org/t/p/w600_and_h900_bestv2{{item.poster_path}}" alt="Card image cap">
<div class="card-body d-flex flex-row">
<h6 class="mb-1" style="margin-top: 10px;">release date : {{item.release_date}}</h6>
<!-- <p class="mb-1">Description : {{item.overview}}</p> --></div>
<p class="card-body">Description : {{item.overview}}</p></div>
</div>
we have the “Get things executed” lifestyle at our place of work. There are not any excuses, no if’s or however’s in our dictionary. committed to navigating the ship of creativity to create cell answers, we resolve the real-lifestyles troubles of our clients and their clients. Our passion for work has won us many awards, year after 12 months.
© Copyright Shadbox. All Rights Reserved
Rate Blog :
Share on :
Do you have any blog suggestion? please click on the link