0

Good day Community,

I have four check-box with values assigned to them. And the project Im working on will have different logged-in users. I would like the data to be shared between the users without hard-coding the values. Is there anyway i can save the values, so that when i reload the page or another user logs into their profile, they can access the check-box data without using a database?

<div *ngIf="data.user.isSeller">
    <div class="checkbox">
        <label><input type="checkbox" (click)="Processing = !Processing" value="Processing" >Processing</label>
    </div>
    <div class="checkbox">
        <label><input type="checkbox"(click)="Shipping = !Shipping" value="Shipping">Shipping</label>
    </div>
    <div class="checkbox">
        <label><input type="checkbox" (click)="Delivered = !Delivered" value="Delivered">Delivered</label>
    </div>
    <div class="checkbox">
        <label><input type="checkbox" (click)="Closed = !Closed" value="Closed" >Delivered and Closed</label>
    </div>
</div>
<div *ngIf = "Processing">
    <i class="fa fa-check"> Processing..... <br>
    Your order has been recieved and it is being processed.
    </i>
</div>
<br>
<div *ngIf = "Shipping">
    <i class="fa fa-check">Shipping</i>
</div>
<br>
<div *ngIf = "Delivered">
    <i class="fa fa-check"> Delivered</i>
</div>
<br>
<div *ngIf = "Closed">
    <i class="fa fa-check">Delivered and Closed</i>
</div>

Thank you

alou
  • 1,432
  • 13
  • 16
Chris
  • 5
  • 4

3 Answers3

1

Without using a database, maybe but you need some other way of persisting those data in the server, like writing them to a file or keeping them in server memory, none of which is a good idea.

So, no. You need to put them in a database and serve them to your users.

alou
  • 1,432
  • 13
  • 16
0

You can save the data to Local Storage or Cookies if you want to share between other user, re-asign within other user login, and clear it when you want. Take a quick view at this post: Angular 6: saving data to local storage

0

You can 'temporarily' save data in JSON . I repeat : temporarily

Method 1 :

Use json-server

https://my-json-server.typicode.com/

fault : As long as you keep the json file, your data will be there. When the file is gone, you lost your data.

Method 2:

Use a variable in service class to save data

fault : when app is off, data is gone. Until then you can use it. Maybe put some pre defined data in it