How to convert string to object in Angularjs

This question already has an answer here:

  • Parse JSON in JavaScript? [duplicate] 16 answers

  • You can do it with angular.fromJson()

    in your sample, it would have been $scope.tmp = angular.fromJson($scope.text);

    The difference between JSON.Parse() and angular.fromJson , is that angular will check to make sure a string is provided. If it is already an object, it will return the same object.

    链接地址: http://www.djcxy.com/p/8488.html

    上一篇: 将字符串从JSON.stringify转换为数组

    下一篇: 如何将字符串转换为Angularjs中的对象