I basically have a button that once pressed will output whatever has been typed into the user input.
However my function that assigns the user input to a variable isn't being recognised for some odd reason?
app.component.html:
<div style="text-align:center">
<h1>Word Hider</h1>
<p></p>
<input type="text" class="wordHide" value="Insert Text">
<p></p>
<button id='userIn' (click)='takeUserStr()'>Submit!</button>
<p></p>
<button>Hide Word!</button>
<div>
Your Word Is: {{ userWord }}
</div>
</div>
app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, OnInit } from '@angular/core';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
userWord = 'this is a test';
********************function***********************
takeUserStr(event: any) {
this.userWord = (<HTMLInputElement>event.target).value;
}
}