Angular UI 网格显示编码数据

Angular UI Grid show encoded data

有没有办法以

格式显示数据
"{\"brand\":\"newBrand\",\"Id\":\"1\",\"field\":\"1\",\"date\":1437487498449,\"period\":2,\"newUser\":0}"

在 table(单行)?

中分别显示它们(相应列中的每条数据 - column1 - Id,column2 - brand 等)

我解析 (JSON.parse) 数据,但我无法将它们分开并显示在适当的列中 - 所有数据都转到第一列。

我正在尝试重现plunkr

UI-Grid 将对象数组作为数据,因此您需要将 json 包含在数组中。只需在解析的 json 对象周围添加方括号。

  $scope.myData = [JSON.parse("{\"brand\":\"newBrand\",\"Id\":\"1\",\"field\":\"1\",\"date\":1437487498449,\"period\":2,\"newUser\":0}")];

同样适用于多个 json 个对象:

  $scope.myData = [
    JSON.parse("{\"brand\":\"newBrand\",\"Id\":\"1\",\"field\":\"1\",\"date\":1437487498449,\"period\":2,\"newUser\":0}"),
    JSON.parse("{\"brand\":\"newBrand\",\"Id\":\"1\",\"field\":\"1\",\"date\":1437487498449,\"period\":2,\"newUser\":0}")
  ];