javascript - 如何从 json 中检索 angularjs 表达式的数据?

标签 javascript json angularjs

我有一个 json 响应,我想将数据填充到字段中,如何使用 angularjs 表达式来完成该任务。我如何将 json 响应中的值映射到 html 页面。

到目前为止我尝试过这个...

HTML

<div class="row">
    <div class="col-md-6">
        <label class="control-label">Rule Id</label>
        <div>{{ruleIdentifier}}</div>
    </div>
    <div class="col-md-6">
        <label class="control-label">SubpartID</label>
        <div>{{subpartId}}</div>
    </div>
</div>

MODALCTRL.JS

lrrDetails.findlrrDetail().then(function(response){
  $scope.lrrDetail = response;
  $scope.ruleidentifier = $scope.lrrDetail.id
})

工厂.JS

findlrrDetail: function(result){
        return $http.get('/third-party-management/rest/lrr/17181');
        $scope.lrrDetail = result.data;
    },

JSON.JS

    {"id":1,
"sourceFeedKey":15,
"lookupCode":"RS_DELETED",
"externalIndintifier":"47",
"subpartCitationIndicator":"1",
"ruleIdentifier":"13",
"ruleSubpartExternalIdentifier":"55029",
"subpartCount":null,
"subpartCitationCount":null,
"citationValue":"18 U.S.C. 2711",
"ruleName":"Definitions For Chapter",
"highValueSummary":"This chapter provides guidance on stored wire and electronic communications and transactional records access and contains provisions of the Stored Communications 
Act.","
issuingAuthKey":873,
"citationAsOfDate":1325566800000,
"vedourActivityType":"Internal Activity",
"vedourActivityDescription1":null,
"vedourActivityDescription2":null,
"applicabilityIndicator":"0",
"auditGroupCategory":null,
"auditGroupIndicator":null,
"citationCoreIndicator":null,
"createdDate":1352497145890,
"modifiedDate":1375313477250,
"createdBy":"ERDSYSTEM",
"mofifiedBy":"NBKQNXS",
"regulatoryInventoryName"

最佳答案

以下是如何使用 $http 以及如何填充数据的示例。希望它对你有用。 http://jsfiddle.net/8qumcq80/1/

关于javascript - 如何从 json 中检索 angularjs 表达式的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28588118/

相关文章:

javascript - 从 javascript 中的对象数组替换模板中的键

javascript - 使用客户端脚本检测访问者是否在索引页面上

c# - Newtonsoft 转义 JSON 字符串无法反序列化为对象

javascript - angular chart.js 的数据属性中的表达式

javascript - 文本和光标样式通过 JavaScript 更改 : browser compatibility problems

javascript - 如何在 Javascript 中切片对象?

java - 可以使用 JSON 和多部分表单的 REST 服务

json - Rswag 模式不会因数组中对象的无效属性而失败

javascript - 我需要使用服务来跨多个 View 存储、保存和提供可用数据

javascript - 我如何从本地主机 :5000 to localhost:3000 发送 http post 请求