简体   繁体   中英

Javascript: Push JSON String as Value of an Input String (Escape/Unescape)

Following Situation (see plunker here: http://plnkr.co/edit/fOJ5zRvqCKvOC3olik8S?p=preview ):

在此处输入图片说明

<input ng-model="x" type="text">
<button ng-click="add(x)"> push input's value </button>

Text-Input has a JSON-String as value (I put it manually)

{ "i":3, "j":5 }

and I want to transfer its value and push it afterwards in Controller into an array. As you can see I've an escaped version of it in the array, what I want to avoide.

How should my escape/unescape strategy look ? Where should I begin?

使用以下内容:

$scope.a.push(JSON.parse(param));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM