工作中,今天用到了angular.fromJson()函数。刚开始拿下面的string转成json,可是报错了,oh,my god,难道用错了?!
angular.fromJson("[{'name':'zhangSan','password':'123'},{'name':'liSi','password':'321'}]") Uncaught SyntaxError: Unexpected token ' in JSON at position 1
难道是引号的原因?angular的api竟然连这个有限制!
angular.fromJson('[{"name":"zhangSan","password":"123"},{"name":"liSi","password":"321"}]') -->(2) [Object,Object]
呵呵。希望angular 4没这个问题。
原文链接:https://www.f2er.com/angularjs/147074.html