Now the best part is that you're probably fetching this from the database so you could just fetch json from the server and pass that to the model like so:
// main.js
$.getJSON('/person/find/1').then(function(person) {
$scope.person = person
})
The best part of using the Model View paradigm is that you can add models/fields with minimal changes to the code. Just add that to your backend and your view and you're good to go.
16
u/snarkyturtle Jun 09 '16
With jQuery, updating something would be akin to doing something like:
this is well and dandy until you have a ton of fields to update
What MV* solutions allow you to do is declare a model in a .js file and use binding to do what all the $.text calls would do:
Now the best part is that you're probably fetching this from the database so you could just fetch json from the server and pass that to the model like so:
The best part of using the Model View paradigm is that you can add models/fields with minimal changes to the code. Just add that to your backend and your view and you're good to go.