August 2016
Intermediate to advanced
360 pages
8h 44m
English
Or, Creating Notes and Calling the API
Today we’ll write the code to accept user input and create a note from the new note screen. Then we’ll get the notes displayed in a list on the main screen. We’ll also get the notes saving to and loading from the API.
Let’s get started by creating a new note. First, to store note data locally we’ll create a data model.
Add this class to a new file called data/NotesDataModel.js:
| | 'use strict'; |
| | |
| | class NotesDataModel { |
| | |
| | notes:Array<Object> = []; |
| | |
| | createNewNote(title:String, body:String) { |
| | this.notes.push({title: title, body: body}); |
| | } |
| | } |
| |
Read now
Unlock full access