I'm struggling to showcase the data that I've already transferred from another component in my form. Below is the interface for reference: https://i.sstatic.net/zOWvU.png
Even after attempting to utilize ngModel, it still didn't yield the desired results. Here's a snippet of my code:
form.ts :
import { Component, OnInit} from '@angular/core';
import {NgForm} from '@angular/forms';
import { Route } from '@angular/router';
import { SharedService } from '../services/shared.service';
@Component({
selector: 'app-repo',
templateUrl: './repo.component.html',
styleUrls: ['./repo.component.scss']
})
export class RepoComponent implements OnInit {
data = this.shared.getData();
constructor( private router: Router, private shared: SharedService ) {
if(this.data){
console.log(this.data);
}
else{
this.router.navigateByUrl('/Deals');
}
}
ngOnInit(): void {
}
}
form.html:
<form #form="ngForm" autocomplete="off" >
<div class="form-group">
<label>Deal Class</label>
<input required type="text" id="dealclass" name="Dealclass" [(ngModel)]="data.DEALCLASS" style="width: 400px;">
</div>
</form>**
If you have any insights or suggestions, they would be greatly appreciated! Thank you and may your day be fabulous :)