在表中显示json数据

时间:2017-08-02 11:39:05

标签: angularjs json

我在控制器中直接添加了json数据,我需要在表格中显示它。

 var app = angular
                    .module("myApp", [])
                    .controller("myCtrl", function ($scope, $http, $timeout) {
                    var userList=[
                    {
                        "name":"John",
                        "age":"22",
                        "dept":"admin"
                    },
                    {
                        "name":"Riya",
                        "age":"21",
                        "dept":"Java"
                    }
                    ];
                    });

怎么做?

示例代码:https://jsfiddle.net/ots8saak/

1 个答案:

答案 0 :(得分:2)

将var更改为$ scope,

 var userList= [...];

$scope.userList = [...];

<强> WORKING FIDDLE