checkbox enable disable on users will in angular

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tsadfsfsd
    New Member
    • Jan 2020
    • 4

    #1

    checkbox enable disable on users will in angular

    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.
  • dev7060
    Recognized Expert Contributor
    • Mar 2017
    • 656

    #2
    Two things:
    - Show what you've tried so far.
    - The question has been posted in the wrong category.

    [MOD] thread moved to correct section
    Last edited by gits; Jan 17 '20, 10:06 AM. Reason: add info about thread was moved to javascript section

    Comment

    • tsadfsfsd
      New Member
      • Jan 2020
      • 4

      #3
      Code:
      <form [formGroup]="paymentdetailForm" class="form-horizontal" (ngSubmit)="onSubmit()">
                        <input type="checkbox"  style="margin-top: 20px" formControlName="status" (click)="checkclick()" > <b>Enable Razorpay Payment</b>
                        <div *ngIf="paymentdetailForm.controls.status.value">
                            <div class="radio">  
                                        <label>  
                                        <input type="radio" name="" formControlName="payment_mode" [value]="1"  (click)="setradio('1')"  [checked]='true' >Test </label>  
                                     </div>  
                                     <div class="radio">  
                                      <label>  
                                         <input formControlName="payment_mode" type="radio" [value]="2" (click)="setradio('2')"   >  
                                         Live
                                       </label>  
                                     </div>  
                                     
                                     <div class="form-group" *ngIf="isSelected('1')" >  
                                      Test Key : <input type="text" class="form-control" formControlName="key_id" [(ngModel)] = "key_id"/>
                                        <input type="text" formControlName="id" hidden/>
                                        Test SlatKey : <input type="text" class="form-control" formControlName="salt_key" [(ngModel)] = "salt_key"/> 
                                     </div>  
                                     
                                     <div class="form-group" *ngIf="isSelected('2')">  
                                      Live Key : <input class="form-control" type="text" formControlName="key_id"/>
                                      Live SlatKey : <input type="text" class="form-control" formControlName="salt_key"/>
                                     </div>
                                     <button type="submit" class="btn btn-primary" style="background:#051f71; margin-left: 12px;
          margin-top: 50px;">Submit</button>
            </div>
                          </form>
      Last edited by gits; Jan 17 '20, 09:56 AM. Reason: added code tags

      Comment

      • tsadfsfsd
        New Member
        • Jan 2020
        • 4

        #4
        this is my code kindly check and ask if anything not understandable. ..

        Comment

        • tsadfsfsd
          New Member
          • Jan 2020
          • 4

          #5
          is there any way to solve this problem of mine....

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            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.
            Last edited by gits; Jan 17 '20, 01:52 PM.

            Comment

            Working...