Angular 6 checkbox triggers change when ngModel value is true
up vote
0
down vote
favorite
I have ngFor and inside I have checkbox.
<input type="checkbox" name="checkbox-i"
(change)="clickOn(test.fav)" [(ngModel)]="test.fav" />
clickOn() event triggers, when test.fav value is true. Anybody used to have this problem? Regards.
angular checkbox angular6 angular-ngmodel
add a comment |
up vote
0
down vote
favorite
I have ngFor and inside I have checkbox.
<input type="checkbox" name="checkbox-i"
(change)="clickOn(test.fav)" [(ngModel)]="test.fav" />
clickOn() event triggers, when test.fav value is true. Anybody used to have this problem? Regards.
angular checkbox angular6 angular-ngmodel
Do you mean it doesn't fire angModelChange
event when value isfalse
?
– Pankaj Parkar
Nov 10 at 14:24
Or that it triggers initially, wihout any user action?
– ConnorsFan
Nov 10 at 14:24
@PankajParkar I had to say (change). (change) function fires when checkbox ngModel value is true.
– KoboldMines
Nov 10 at 14:30
It triggers regardles of value.
– ritaj
Nov 10 at 14:36
@KoboldMines can you please provide me a stackblitz with reproducible problem?
– Pankaj Parkar
Nov 10 at 15:02
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have ngFor and inside I have checkbox.
<input type="checkbox" name="checkbox-i"
(change)="clickOn(test.fav)" [(ngModel)]="test.fav" />
clickOn() event triggers, when test.fav value is true. Anybody used to have this problem? Regards.
angular checkbox angular6 angular-ngmodel
I have ngFor and inside I have checkbox.
<input type="checkbox" name="checkbox-i"
(change)="clickOn(test.fav)" [(ngModel)]="test.fav" />
clickOn() event triggers, when test.fav value is true. Anybody used to have this problem? Regards.
angular checkbox angular6 angular-ngmodel
angular checkbox angular6 angular-ngmodel
edited Nov 10 at 17:19
HDJEMAI
4,051123653
4,051123653
asked Nov 10 at 14:20
KoboldMines
376
376
Do you mean it doesn't fire angModelChange
event when value isfalse
?
– Pankaj Parkar
Nov 10 at 14:24
Or that it triggers initially, wihout any user action?
– ConnorsFan
Nov 10 at 14:24
@PankajParkar I had to say (change). (change) function fires when checkbox ngModel value is true.
– KoboldMines
Nov 10 at 14:30
It triggers regardles of value.
– ritaj
Nov 10 at 14:36
@KoboldMines can you please provide me a stackblitz with reproducible problem?
– Pankaj Parkar
Nov 10 at 15:02
add a comment |
Do you mean it doesn't fire angModelChange
event when value isfalse
?
– Pankaj Parkar
Nov 10 at 14:24
Or that it triggers initially, wihout any user action?
– ConnorsFan
Nov 10 at 14:24
@PankajParkar I had to say (change). (change) function fires when checkbox ngModel value is true.
– KoboldMines
Nov 10 at 14:30
It triggers regardles of value.
– ritaj
Nov 10 at 14:36
@KoboldMines can you please provide me a stackblitz with reproducible problem?
– Pankaj Parkar
Nov 10 at 15:02
Do you mean it doesn't fire a
ngModelChange
event when value is false
?– Pankaj Parkar
Nov 10 at 14:24
Do you mean it doesn't fire a
ngModelChange
event when value is false
?– Pankaj Parkar
Nov 10 at 14:24
Or that it triggers initially, wihout any user action?
– ConnorsFan
Nov 10 at 14:24
Or that it triggers initially, wihout any user action?
– ConnorsFan
Nov 10 at 14:24
@PankajParkar I had to say (change). (change) function fires when checkbox ngModel value is true.
– KoboldMines
Nov 10 at 14:30
@PankajParkar I had to say (change). (change) function fires when checkbox ngModel value is true.
– KoboldMines
Nov 10 at 14:30
It triggers regardles of value.
– ritaj
Nov 10 at 14:36
It triggers regardles of value.
– ritaj
Nov 10 at 14:36
@KoboldMines can you please provide me a stackblitz with reproducible problem?
– Pankaj Parkar
Nov 10 at 15:02
@KoboldMines can you please provide me a stackblitz with reproducible problem?
– Pankaj Parkar
Nov 10 at 15:02
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Use reference
of checkbox element and pass the value or use ngModelChange
Replace the below code
<input type="checkbox" name="checkbox-i" (change)="clickOn(test.fav)" [(ngModel)]="test.fav" />
by
<input type="checkbox" name="checkbox-i" #test
(change)="clickOn(test.value)" [(ngModel)]="test.fav" />
or
<input type="checkbox" name="checkbox-i" #test
(ngModelChange)="clickOn($event)" [(ngModel)]="test.fav" />
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Use reference
of checkbox element and pass the value or use ngModelChange
Replace the below code
<input type="checkbox" name="checkbox-i" (change)="clickOn(test.fav)" [(ngModel)]="test.fav" />
by
<input type="checkbox" name="checkbox-i" #test
(change)="clickOn(test.value)" [(ngModel)]="test.fav" />
or
<input type="checkbox" name="checkbox-i" #test
(ngModelChange)="clickOn($event)" [(ngModel)]="test.fav" />
add a comment |
up vote
0
down vote
Use reference
of checkbox element and pass the value or use ngModelChange
Replace the below code
<input type="checkbox" name="checkbox-i" (change)="clickOn(test.fav)" [(ngModel)]="test.fav" />
by
<input type="checkbox" name="checkbox-i" #test
(change)="clickOn(test.value)" [(ngModel)]="test.fav" />
or
<input type="checkbox" name="checkbox-i" #test
(ngModelChange)="clickOn($event)" [(ngModel)]="test.fav" />
add a comment |
up vote
0
down vote
up vote
0
down vote
Use reference
of checkbox element and pass the value or use ngModelChange
Replace the below code
<input type="checkbox" name="checkbox-i" (change)="clickOn(test.fav)" [(ngModel)]="test.fav" />
by
<input type="checkbox" name="checkbox-i" #test
(change)="clickOn(test.value)" [(ngModel)]="test.fav" />
or
<input type="checkbox" name="checkbox-i" #test
(ngModelChange)="clickOn($event)" [(ngModel)]="test.fav" />
Use reference
of checkbox element and pass the value or use ngModelChange
Replace the below code
<input type="checkbox" name="checkbox-i" (change)="clickOn(test.fav)" [(ngModel)]="test.fav" />
by
<input type="checkbox" name="checkbox-i" #test
(change)="clickOn(test.value)" [(ngModel)]="test.fav" />
or
<input type="checkbox" name="checkbox-i" #test
(ngModelChange)="clickOn($event)" [(ngModel)]="test.fav" />
answered Nov 10 at 16:42
Sunil Singh
5,3741624
5,3741624
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239859%2fangular-6-checkbox-triggers-change-when-ngmodel-value-is-true%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you mean it doesn't fire a
ngModelChange
event when value isfalse
?– Pankaj Parkar
Nov 10 at 14:24
Or that it triggers initially, wihout any user action?
– ConnorsFan
Nov 10 at 14:24
@PankajParkar I had to say (change). (change) function fires when checkbox ngModel value is true.
– KoboldMines
Nov 10 at 14:30
It triggers regardles of value.
– ritaj
Nov 10 at 14:36
@KoboldMines can you please provide me a stackblitz with reproducible problem?
– Pankaj Parkar
Nov 10 at 15:02