Professional Documents
Culture Documents
html
-------------------------
<form>
<label for="fromCurrency">Source CCY:</label>
<select [(ngModel)]="fromCurrency" id="fromCurrency">
<option value="USD">USD</option>
<option value="GBP">GBP</option>
<option value="INR">INR</option>
</select>
<br>
<br>
<label for="toCurrency">Target CCY:</label>
<select [(ngModel)]="toCurrency" id="toCurrency">
<option value="USD">USD</option>
<option value="GBP">GBP</option>
<option value="INR">INR</option>
</select>
<br><br>
<label for="amount">Amount (Rs):</label>
<input type="number" [(ngModel)]="amount" id="amount">
<br>
<br>
<button (click)="submit()">Submit</button>
<div id="resValue">
{{ amount | convertCurrency:fromCurrency:toCurrency }} {{ toCurrency }}
</div>
</form>
app.component.ts
----------------------
@Pipe({
name: 'convertCurrency'
})
export class ConvertCurrencyPipe implements PipeTransform {
exchangeRates = {
USD: 1.126735,
GBP: 0.876893,
INR: 79.677056
};
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
fromCurrency = 'USD';
toCurrency = 'GBP';
amount = 100;
submit() {
// Do something when the form is submitted
console.log('Form submitted with values:');
console.log(`fromCurrency: ${this.fromCurrency}`);
console.log(`toCurrency: ${this.toCurrency}`);
console.log(`amount: ${this.amount}`);
}
}
app.module.ts
_______________
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }