2

Good day, I recently learn about angularjs. Now, i'm trying to show data from json in table. I'm using codeigniter

<script src="<?=base_url();?>assets/app_angular/angular.min.js"></script>
    <script>
    var app = angular.module('myApp', []);
    app.controller('listsupport', function($scope, $http) {
        $http.get("<?=base_url();?>newchat/listsupport").then(function (response) {
                console.log(response);
                $scope.names = response.data.records;
        });
    });
</script>

I have this Json

    [{"username":"0600260","password":"81dc9bdb52d04dc20036dbd8313ed055","Type":"TP010","Flag":1,"last_login":"1900-01-01 00:00:00.000","loginstatus":0,"alias":null,"FullName":"ZAENAL ABIDIN"},
{"username":"1602762","password":"b59c67bf196a4758191e42f76670ceba","Type":"TP001","Flag":1,"last_login":"2017-05-02 13:43:15.200","loginstatus":1,"alias":"boby","FullName":"BOBY KURNIAWAN"},
 {"username":"0903380","password":"81dc9bdb52d04dc20036dbd8313ed055","Type":"TP010","Flag":1,"last_login":"1900-01-01 00:00:00.000","loginstatus":0,"alias":null,"FullName":"JUDY SJARIP"},
 {"username":"1004385","password":"81dc9bdb52d04dc20036dbd8313ed055","Type":"TP010","Flag":1,"last_login":"1900-01-01 00:00:00.000","loginstatus":0,"alias":null,"FullName":"RENDY SETIAWAN"},
 {"username":"1004502","password":"81dc9bdb52d04dc20036dbd8313ed055","Type":"TP010","Flag":1,"last_login":"1900-01-01 00:00:00.000","loginstatus":0,"alias":null,"FullName":"BANGBANG IRAWAN "},{"username":"1106975","password":"81dc9bdb52d04dc20036dbd8313ed055","Type":"TP010","Flag":1,"last_login":"1900-01-01 00:00:00.000","loginstatus":0,"alias":null,"FullName":"ABDUL ROCHIM"},   {"username":"1501815","password":"81dc9bdb52d04dc20036dbd8313ed055","Type":"TP010","Flag":1,"last_login":"1900-01-01 00:00:00.000","loginstatus":0,"alias":null,"FullName":"KHAIRUNNAS "}]

and here is HTML table

<div ng-app="myApp" ng-controller="listsupport"> 
             <table>
              <tr ng-repeat="x in names">
                <td>{{ x.FullName }}</td>

              </tr>
            </table>
        </div>

With my script above, my html is empty. So how can i show the json in my HTML table with angular js ?

Thanks in advance and sorry for my bad english.

2
  • what display console.log(response); ? Commented May 2, 2017 at 7:00
  • @Hadi Empty, and i wonder why Commented May 2, 2017 at 7:00

1 Answer 1

1

make sure your addressing response properly in js...i think u need to give like $scope.names = response.data have a look on this plunker

i tried with placing ur json data in to a json file

Sign up to request clarification or add additional context in comments.

2 Comments

so i just need to do this $scope.names = response.data;
if your getting response like how its shown in plunker then response.data is enough

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.