I am trying to read the value of a switch - 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 html based on the fact that the value of the radio button is being created or is being continued.
What I tried:
- Retrieving switch values in typescript file using
document.getElementById- Property checkednot found. - Reading a value using
model.functionby definition modelin typescript. Unable to access the variable model, obviously! - I tried to use it
[(ngModel)]- it didn’t work either.
Please suggest a twist for this.
source
share