I'm trying to read the radio button value - in angular 2,
index.html
<input type="radio" id="options1" name="function" value="create">
<input type="radio" id="options2" name="function" value="continue">
index.ts
@Component({
selector: 'function',
templateUrl: './client/components/function/index.html',
styleUrls: ['./client/components/function/index.css'],
providers: [],
directives: [ROUTER_DIRECTIVES]
})
I need to display a div in the html based on if radio button value is create or continue.
What I've tried:
- Fetching values of radio button in the typescript file using
document.getElementById
- Propertychecked
wasn't getting detected. - Reading the value using
model.function
by defining amodel
in the typescript. Unable to access themodel
variable, obviously! - Tried using
[(ngModel)]
- that didn't work either.
Please suggest a turnaround for this.