By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,366 Members | 1,275 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,366 IT Pros & Developers. It's quick & easy.

checkbox enable disable on users will in angular

P: 4
i want to check a checkbox and even if the page is refreshed i want the state of checkbox(enable or disable previously)must be same and only after the user change the state of checkbox it should be undone.
Jan 17 '20 #1
Share this Question
Share on Google+
5 Replies

Expert 100+
P: 333
Two things:
- Show what you've tried so far.
- The question has been posted in the wrong category.

[MOD] thread moved to correct section
Jan 17 '20 #2

P: 4
Expand|Select|Wrap|Line Numbers
  1. <form [formGroup]="paymentdetailForm" class="form-horizontal" (ngSubmit)="onSubmit()">
  2.                   <input type="checkbox"  style="margin-top: 20px" formControlName="status" (click)="checkclick()" > <b>Enable Razorpay Payment</b>
  3.                   <div *ngIf="paymentdetailForm.controls.status.value">
  4.                       <div class="radio">  
  5.                                   <label>  
  6.                                   <input type="radio" name="" formControlName="payment_mode" [value]="1"  (click)="setradio('1')"  [checked]='true' >Test </label>  
  7.                                </div>  
  8.                                <div class="radio">  
  9.                                 <label>  
  10.                                    <input formControlName="payment_mode" type="radio" [value]="2" (click)="setradio('2')"   >  
  11.                                    Live
  12.                                  </label>  
  13.                                </div>  
  15.                                <div class="form-group" *ngIf="isSelected('1')" >  
  16.                                 Test Key : <input type="text" class="form-control" formControlName="key_id" [(ngModel)] = "key_id"/>
  17.                                   <input type="text" formControlName="id" hidden/>
  18.                                   Test SlatKey : <input type="text" class="form-control" formControlName="salt_key" [(ngModel)] = "salt_key"/> 
  19.                                </div>  
  21.                                <div class="form-group" *ngIf="isSelected('2')">  
  22.                                 Live Key : <input class="form-control" type="text" formControlName="key_id"/>
  23.                                 Live SlatKey : <input type="text" class="form-control" formControlName="salt_key"/>
  24.                                </div>
  25.                                <button type="submit" class="btn btn-primary" style="background:#051f71; margin-left: 12px;
  26.     margin-top: 50px;">Submit</button>
  27.       </div>
  28.                     </form>
Jan 17 '20 #3

P: 4
this is my code kindly check and ask if anything not understandable...
Jan 17 '20 #4

P: 4
is there any way to solve this problem of mine....
Jan 17 '20 #5

Expert Mod 5K+
P: 5,390
so as far as i understand your question - you want to make the state of a checkbox persistent across user sessions?

If so - then there are several other questions. Is the (or a) user logged in? Then you would need to make it persistent for that specific user.

If not - do you expect a PC (or other device) is used by only 1 user? This might decide if the persistence is good or not.

There are different ways to achieve that:

1. store the state on your server in a session or database (depending on how long the persistence should be)

2. store state clientside in a cookie or local storage

PS: if a user logs in from another machine and you want the checkbox still being in that state - then option 1. and storing in a database is the only way to go - so what i want to say is that a solution depends on specific requirements - but for each of them there will be a solution.
Jan 17 '20 #6

Post your reply

Sign in to post your reply or Sign up for a free account.