Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a Json file that I would like to output into a table. I am using $http.get request and $q to retrieve Json object. I am trying to figure out how to get that data into a table that will display on the page. Any advice will help

AngularJS

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

app.controller("PeopleCtrl", function ($scope, $http, $q) {
    $scope.AdminUserSettings = {
        dataSource: new data.dataSource({
            load: function () {
                var def = $.Deferred();
                $http({
                    method: 'GET',
                    url: '//This is where my localhost:xxxx/api/ is going'
                }).success(function (data) {
                    def.resolve(data);
                });
                return def.promise();
            }
        })
    }
})

HTML

<div ng-app="myApp">
    <div ng-controller="PeopleCtrl">
        <table>
            <tr>
                <th>ID</th>
                <th>UserName</th>
                <th>UserRoleID</th>
            </tr>
            <tr ng-repeat="person in AdminUser">
                <td>{{person.ID}}</td>
                <td>{{person.UserName}}</td>
                <td>{{person.UserRoleID}}</td>
            </tr>
        </table>
    </div>
</div>

JSON

[{"ID":5,"UserName":"JohnSmith","UserRoleID":1},{"ID":7,"UserName":"BobBrown","UserRoleID":3}...etc.]
share|improve this question
    
So.... Where is your PeopleCtrl, since that's what you are using to output the table? Where is AdminUser defined? –  Kevin B yesterday
    
So, AdminUser is defined in a controller in my Api project. I am able to pull the json data by referencing that localhost url. PeopleCtrl is not defined because I am not sure how to define it inside of the AngularJS file. This is a big part of the problem I am stuck on. –  Tim yesterday
    
so.... you have a service, and a controller that you're not using,and you need to know how to make another controller? I'm confused why your'e asking here if you don't know what you need. Your code won't work without a PeopleCtrl unless you stop trying to use it. –  Kevin B yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.