Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component } from '@angular/core';
- import { IonicPage, NavController } from 'ionic-angular';
- // import { NoteServiceProvider } from "../../providers/note-service/note-service";
- import { NoteInterface } from "../../app/Note-Interface";
- import { Storage } from '@ionic/storage';
- import { FormGroup, Validators, FormControl } from "@angular/forms";
- import { HomePage } from "../home/home";
- @IonicPage()
- @Component({
- selector: 'page-new-note',
- templateUrl: 'new-note.html',
- })
- export class NewNotePage {
- private Notes: NoteInterface[] = [];
- formGroup: FormGroup;
- note: NoteInterface;
- date: Date = new Date();
- title: string = '';
- content: string = '';
- constructor(public navCtrl: NavController, private storage: Storage) {
- this.formGroup = new FormGroup({title: new FormControl(), content: new FormControl(), date: new FormControl()});
- }
- ionViewDidLoad() {
- }
- addNewNote(note: NoteInterface) {
- this.saveNoteInStorage(note);
- this.navCtrl.push(HomePage);
- }
- saveNoteInStorage(note: NoteInterface) {
- note.timeStamp = Date.now();
- this.Notes = this.Notes || [];
- this.Notes.push(note);
- localStorage.setItem('NOTES', JSON.stringify(this.Notes));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement