December 2014
Intermediate to advanced
346 pages
6h 14m
English
AngularJS provides you with a JSON conversion tool, the json filter, to serialize JavaScript objects into prettified JSON code. This filter isn't so much in use for production applications as it is used for real-time inspection of your scope objects.
Suppose your controller is set up as follows with a prefilled user data object:
(app.js)
angular.module('myApp', [])
.controller('Ctrl', function ($scope) {
$scope.user = {
id: 123,
name: {
first: 'Jake',
last: 'Hsu'
},
username: 'papatango',
friendIds: [5, 13, 3, 1, 2, 8, 21],
// properties prefixed with $$ will be excluded
$$no_show: 'Hide me!'
};
});Your user object can be serialized in the template, as follows:
(index.html) <div ng-app="myApp"> ...
Read now
Unlock full access