【问题标题】:To present JSON key value in Angular front end在 Angular 前端显示 JSON 键值
【发布时间】:2017-01-06 12:17:13
【问题描述】:

我需要在前端(Angular 1)呈现下面的 JSON。

{
"test.employee.name" : "Royal"
}

想在前端同时呈现key和value。 json 数据将存储在 .json 文件中。

【问题讨论】:

  • 你应该展示你尝试过的和没有用的,而不是仅仅要求别人给你代码。
  • @Claies - 我是新手。谢谢你的信息!!。

标签: angularjs angular-ui-bootstrap


【解决方案1】:

var app = angular.module("app", []);

app.controller("ListCtrl", ["$scope",
  function($scope) {
    var vm = this;
     vm.events = {
"test.employee.name" : "Royal"
};
  }

]);
<!DOCTYPE html>
<html>
<head>
  <script data-require="angular.js@1.4.7" data-semver="1.4.7" src="https://code.angularjs.org/1.4.7/angular.js"></script>
  <link rel="stylesheet" href="style.css" />
  <script src="script.js"></script>
</head>
<body ng-app='app'>
  <div ng-controller="ListCtrl as home">
  <div  ng-repeat="(key,value) in home.events  "> 
 "key is:" {{key }}  "value is:" {{value}}</div>
  </div>
</body>
</html>

【讨论】:

    猜你喜欢
    • 2021-12-18
    • 2023-03-08
    • 2021-05-02
    • 2021-01-01
    • 1970-01-01
    • 2021-03-03
    • 1970-01-01
    • 2020-06-28
    • 1970-01-01
    相关资源
    最近更新 更多