I'm new to angular2. I want to store user input from a text area in a variable in my component so I can apply some logic to this input. I tried ngModel
but it doesn't work. My code for the textarea:
<textarea cols="30" rows="4" [(ngModel)] = "str"></textarea>
And inside my component:
str: string;
//some logic on str
But I don't get any value in str
inside my component. Is there an error with the way I'm using ngModule
?
<pre>
<input type="text" #titleInput>
<button type="submit" (click) = 'addTodo(titleInput.value)'>Add</button>
</pre>
{
addTodo(title:string) {
console.log(title);
}
}