angular.fromJson
json | string |
JSON 字符串 |
<!DOCTYPE HTML> <html ng-app="exampleApp"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script src="angular.min.js"></script> <script> var exampleApp = angular.module(‘exampleApp‘,[]); exampleApp.controller(‘ShowController‘,[‘$scope‘, function($scope){ $scope.fromJson = function() { var strUser = "{\"firstName\":\"fox\",\"lastName\":\"zhang\"}"; var objUser = angular.fromJson(strUser); alert(objUser.firstName); } }]); </script> </head> <body> <div id="test">博弈网络科技</div> <div> <div> angular.fromJson("{\"firstName\":\"fox\",\"lastName\":\"zhang\"}") </div> <div id="myCtrl" ng-controller="ShowController"> <input type="button" id="btnToJson" ng-click="fromJson()" value="objUser.firstName" /> </div> </div> <hr> </body> </html>?
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。