The Relationship Between Scope and Backend Server Data

Often data that is used for an AngularJS application comes from a backend data source such as a database. In such instances, the scope still acts as the definitive source of data for the AngularJS application. You should use the following rules when interacting with data that is coming from the server side:

Image Access data from the database or other backend sources via AngularJS services, which are discussed in a later chapter. This includes both reading and updating data.

Image Ensure that data read from the server updates the scope, which in turn updates the view. Avoid the temptation to manipulate the HTML values directly from the database, which can lead to the scope becoming out of sync with the view.

Image Reflect changes that are made to the database or other backend source in scope as well. You can do this by first updating the scope and then updating the database using a service, or you can update the database and then use the results from the database to repopulate the appropriate values in the scope.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.213.49