SoFunction
Updated on 2025-04-12

Examples of json data conversion and local storage in angularJs

: Convert json object to json string

<!doctype html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <script src=""></script>
</head>
<body>
 <div ng-app="module" ng-controller="ctrl">
 {{data}}
 </div>
 <script>
 var m = ('module', []);
 ('ctrl', ['$scope', function ($scope) {
  $ = {'name': 'Lingling on the road'};
  //Convert json object to json string  ('data', ($));
 }]);
 </script>
</body>
</html>

:Convert strings to json objects

<!doctype html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <script src=""></script>
</head>
<body>
<div ng-app="module" ng-controller="ctrl">
 {{}}
</div>
<script>
 var m = ('module', []);
 ('ctrl', ['$scope', function ($scope) {
  //Alert outputs the string  alert(('data'));
  //Convert string to json object  $ =(('data'));
 }]);
</script>
</body>
</html>

Convert strings to json objects

<!doctype html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <script src=""></script>
</head>
<body>
<div ng-app="module" ng-controller="ctrl">
 {{}}
</div>
<script>
 var m = ('module', []);
 ('ctrl', ['$scope', function ($scope) {
 //Convert string to json object  $ = ('{"username":"Lingling on the road"}');
 }]);
</script>
</body>
</html>

The above examples of json data conversion and local storage in angularJs are all the content I share with you. I hope you can give you a reference and I hope you can support me more.