Advertisement
Shell_Casing

new-note page

May 23rd, 2018
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component } from '@angular/core';
  2. import { IonicPage, NavController } from 'ionic-angular';
  3. // import { NoteServiceProvider } from "../../providers/note-service/note-service";
  4. import { NoteInterface } from "../../app/Note-Interface";
  5. import { Storage } from '@ionic/storage';
  6. import { FormGroup, Validators, FormControl } from "@angular/forms";
  7. import { HomePage } from "../home/home";
  8.  
  9.  
  10. @IonicPage()
  11. @Component({
  12.   selector: 'page-new-note',
  13.   templateUrl: 'new-note.html',
  14. })
  15. export class NewNotePage {
  16.  
  17.   private Notes: NoteInterface[] = [];
  18.  
  19.   formGroup: FormGroup;
  20.   note: NoteInterface;
  21.   date: Date = new Date();
  22.   title: string = '';
  23.   content: string = '';
  24.  
  25.  
  26.  
  27.   constructor(public navCtrl: NavController, private storage: Storage) {
  28.     this.formGroup = new FormGroup({title: new FormControl(), content: new FormControl(), date: new FormControl()});
  29.   }
  30.  
  31.   ionViewDidLoad() {
  32.  
  33.   }
  34.  
  35.   addNewNote(note: NoteInterface) {
  36.     this.saveNoteInStorage(note);
  37.     this.navCtrl.push(HomePage);
  38.   }
  39.  
  40.  
  41.   saveNoteInStorage(note: NoteInterface) {
  42.     note.timeStamp = Date.now();
  43.     this.Notes = this.Notes || [];
  44.     this.Notes.push(note);
  45.     localStorage.setItem('NOTES', JSON.stringify(this.Notes));
  46.   }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement