Convert Json String to Array in Angularjs

July 28, 2019 | Category : Angular

In this artical, i want to show you how to convert string to json array in angular js. we can convert string array to json object using angular.fromjson() in angular. you can see bellow example to converting string to object in angular js.

You can use code javascript function into angular because angular is a js framework. so you can also use core javascript logic here.

few days ago i have php array but when i use in angular js code then it show me as string even i pass as php array. you can see what i was getting string:

{\"name\":\"Hardik\",\"email\":\"\" }

But i need to convert this string to json object so i can use on my angular js code. so i search on google and i found fromjson() of angular function and i make it done. You can also see how to can use angular.fromjson() for converting string to object.


<!doctype html>



<title>AngularJS Convert String to Object Example -</title>

<script src=""></script>


<body ng-app='myapp'>

<div ng-controller="myCtrl"> </div>


<script type="text/javascript">

var app = angular.module('myapp', []);

app.controller('myCtrl', ['$scope', '$http', function ($scope, $http) {

$scope.myTextObj = "{\"name\":\"Hardik\",\"email\":\"\" }";

$scope.myObj = angular.fromJson($scope.myTextObj);







email: ""

name: "Hardik"

I hope it can help you....