The app model

The model is the data that the view and controller work on. It represents the state of the system projected on the view. To determine the model for our own app, we need to detail the features that the app supports. These features include:

  • Supporting the generation of random numbers (original)
  • Supporting input for a user to guess the value (guess)
  • Tracking the number of guesses already made (noOfTries)
  • Giving users hints to improve their guess based on their input (deviation)
  • Giving a success message if the user guesses the number correctly (deviation)

Once we have the feature list, we can now determine what data needs to be tracked and that becomes part of our model. For the preceding feature set, the elements in parentheses denote properties ...

Get AngularJS by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.