0

Demo link

Hi all,

I created a sample for select with multiple columns in AngularJS. which is working fine if I pass the value directly like this:

$scope.rowDatas = [
                     { ID: "09-14-002880", PatientName: "PRAVEEN KUMAR", Gender: "Male", Age: "20", mobileNumber: 9879878971, patientId: "test" },
                     { ID: "09-13-000188", PatientName: "VAR", Gender: "Male", Age: "20", mobileNumber: '', patientId: "ZXC12" },
                     { ID: "09-05-019825", PatientName: "KARMA", Gender: "Male", Age: "29", mobileNumber: '', patientId: "ZA2545635" },
                     { ID: "09-04-010524", PatientName: "FRANKLIN ANTHONY", Gender: "Male", Age: "20", mobileNumber: '', patientId: "Z7552396" },
                     { ID: "09-08-009303", PatientName: "DARYOUSH", Gender: "Male", Age: "29", mobileNumber: '', patientId: "Z2548467" },
                     { ID: "09-12-031048", PatientName: "SMITA", Gender: "Female", Age: "20", mobileNumber: 9880222187, patientId: "Z2296538" },
                     { ID: "09-11-026001", PatientName: "ADITYA DILIP", Gender: "Male", Age: "29", mobileNumber: '', patientId: "Z2277913" }
    ];

But what I exactly need is I need to get the value from factory

dtfactory.getdata().then(function(response){
  //$scope.rowDatas = response.data;
})

Here response.data also contain same data.If I comment direct code and uncomment factory code its not working may I know where I did mistake? can any one help me this.

1
  • Make sure your factory function dtfactory.getdata() should return promise. Or you may share your factory code too. Commented Mar 1, 2016 at 6:48

2 Answers 2

0

Try doing it like this in your controller

$scope.rowDatas = dtfactory.getdata().then(function(response){
  $scope.rowDatas = response.data;
})
Sign up to request clarification or add additional context in comments.

Comments

0

Try the following code:

first get the json data and call the displayTable function:

   dtfactory.getdata().then(function(response){
      $scope.rowDatas = response.data;
      dispalyTable();
    })

    function dispalyTable(){
      $scope.gridOptions = {
                    columnDefs: $scope.gridheaders,
                    rowData: $scope.rowDatas,
                };

         //document.addEventListener('DOMContentLoaded', function() {
            var gridDiv = document.querySelector('#myGrid_'+textBoxId);
            new agGrid.Grid(gridDiv, $scope.gridOptions);
         //}); 
    }

2 Comments

@ Harry thanks for reply, i changed your code, but not working
could you please tell me what is not working..? Is $scope.rowDatas is not updating?

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.