doe
doe

Reputation: 148

how to display an array in angular js

i have a function that gets me data as follows

function Model(){
self.DataArray=[];
    self.GetDepartmentData = function () {
        var params = { shiftsBackward: self.ShiftsBackwardToDisplay, shiftsForward: 1, departmentId:department};
        console.log(params);
         Ajax.Get({
             url: DATA,

            params: params,
            success: function (data) {
                self.DataArray = data[0];

            }

        });
    }
    }

which gets me the output i require as following

Object {data: Array[1]}
data: Array[1]
0: Object
department: "1"
ShiftName: "Day"
Total: 61

how ever when im trying to bind it to the default.aspx page its not showing me anything.i did link the controller to the page

<div ng-controller="controllerData">

       <div ng-model="model.DataArray">

           {{model.department}} 
            {{model.total}}

       </div>

Upvotes: 0

Views: 64

Answers (1)

Hassan Tariq
Hassan Tariq

Reputation: 740

In Order to get Array you should use ng-repeat

   <div ng-repeat="dataarr in DataArray">

      <span> {{dataarr.department}} </span>
      <span> {{dataarr.total}} </span>


   </div>

Upvotes: 4

Related Questions