I developed this app (http://www.anelmad.com) and I am trying to redirect the display of information (dictionary definitions of words) upon submit (Enter or button click) into another page.
The redirection works but the content of the page does not follow.
in home.component.html:
<form #myForm>
(...)
<input type="text" class="form-control" #elem
(keyup)="onNameKeyUp(elem.value)"
[ngModelOptions]="{standalone: true}"
[(ngModel)]="latinButton"
(focus)="onNameKeyUp(elem.value)"
placeholder="Enter"/>
<span class="input-group-append">
<button class="btn btn-outline-secondary" type="submit"
(click)="getWordList()">
<i class="fa fa-search"></i>
</button>
</span>
After this form, I added:
<router-outlet></router-outlet>
Inside home.component.ts, I added (this.router.navigate) with the new page as an argument:
getWordList(){
this.router.navigate(['/words']);
this.webservice.getWords(this.spelling, this.selected)
.subscribe((res: Array<Word>)=> {
(...)
in app.module:
const myRoutes: Routes=[
{path: 'words', component: WordsComponent},
{path: 'about', component: AboutComponent},
{path: 'home', component: HomeComponent},
{path: '', redirectTo: '/home', pathMatch:'full'},
{path: '**', redirectTo: '/home', pathMatch:'full'
]
How do I pass the information to be displayed from the form into the new page (words.component.html)?