feat: get translation from the api
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f812671847
commit
b29171e44a
|
@ -1,9 +1,14 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TranslationService {
|
||||
|
||||
constructor() { }
|
||||
constructor(private http: HttpClient) { }
|
||||
getTranslation(text: String)
|
||||
{
|
||||
return this.http.get('https://api.mymemory.translated.net/get?q='+text+'&langpair=en|cs');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
</ion-card>
|
||||
<ion-card class="welcome-card">
|
||||
<ion-card-content>
|
||||
{{ myinput}} <ion-icon name="arrow-forward-outline"></ion-icon> Output
|
||||
{{ myinput ? myinput: "Input" }} <ion-icon name="arrow-forward-outline"></ion-icon> Output
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
</ion-content>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { Component } from '@angular/core';
|
||||
import {TranslationService} from '../api/translation.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-tab1',
|
||||
|
@ -8,12 +9,16 @@ import { Component } from '@angular/core';
|
|||
export class Tab1Page {
|
||||
|
||||
myinput:String
|
||||
constructor() {
|
||||
this.myinput = "Input ...";
|
||||
constructor(private translationService: TranslationService)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
btnTranslateClicked()
|
||||
{
|
||||
console.log(this.myinput);
|
||||
}
|
||||
btnTranslateClicked()
|
||||
{
|
||||
this.translationService.getTranslation(this.myinput).subscribe( (data) =>
|
||||
{
|
||||
console.log(data);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue