简体   繁体   中英

Angular 5 Typescript - Save Local JSON File

Im trying to make a local app, for myself and save everything in json localy. i have this Posts Interface and array with data build up:

this.p = [{
      posts:{
        id: 'hey man',
        title:     'awdwada',
        description: 'awdawdaw',
        commands: {
            title: 'dawdawdawd',
            description: 'awdawda',
            note: 'wadadaw',
        }
      }

    }
    ];
     const r =  JSON.stringify(this.p);
      console.log(r);

how can i save this into a json file?

posting()      
   {
     this.http.post<any>(this.baseurl).map(res:Response=>{res.json();});
   }
ngOnInit()   
   {
     this.appService.posting().subscribe(data=>this.p=data);
   }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM