Angularjs 以角度Js打印dd dt标记中的数据
我有一个类似这样的数据: controller.jsAngularjs 以角度Js打印dd dt标记中的数据,angularjs,Angularjs,我有一个类似这样的数据: controller.js someControllers.controller('viewDetail',function($scope){ $scope.list = [{ "id":"1", "first_name":"Super", "last_name":"Admin", "email":"superadmin@123.com", "status
someControllers.controller('viewDetail',function($scope){
$scope.list = [{
"id":"1",
"first_name":"Super",
"last_name":"Admin",
"email":"superadmin@123.com",
"status":"1",
"is_superadmin":"1"
}];
});
现在我想以这种方式将这些数据打印到视图中
view.html
<dl>
<dt>id</dt>
<dd>1</dd>
<dt>first_name</dt>
<dd>super</dd>
<dt>last_name</dt>
<dd>Admin</dd>
<dt>email</dt>
<dd>superadmin@123.com</dd>
</dl>
身份证件
1.
名字
超级的
姓
管理
电子邮件
superadmin@123.com
等等
请告诉我怎么做。ng repeat对我不起作用
注意:json对象的内容可能是动态的 首先,您需要将JSON分配给对象,而不是直接分配给$scope
someControllers.controller('viewDetail',function($scope){
$scope.list = [{
"id":"1",
"first_name":"Super",
"last_name":"Admin",
"email":"superadmin@123.com",
"status":"1",
"is_superadmin":"1"
}];
});
并在该对象上使用ng repeat
<dl ng-repeat="item in list">
<dt>id</dt>
<dd>{{item.id}}</dd>
<dt>first_name</dt>
<dd>{{item.first_name}}</dd>
<dt>last_name</dt>
<dd>{{item.last_name}}</dd>
<dt>email</dt>
<dd>{{item.email}}</dd>
</dl>
身份证件
{{item.id}
名字
{{item.first{u name}}
姓
{{item.last_name}
电子邮件
{{item.email}
更新:
如果JSON字段是未知的,则也通过每个JSON对象进行循环
<div class="boredered-box" ng-repeat="item in list">
<dl ng-repeat="(key,value) in item">
<dt>{{key}}</dt>
<dd>{{value}}</dd>
</dl>
</div>
{{key}}
{{value}}
您认为ng repeat在哪里?为什么要用数组覆盖$scope对象?j son对象的内容可能是动态的。你是说字段吗?是的,字段是动态的。它可能是除上面列出的以外的任何东西