0

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>
6
  • Instead of model.DataArray can you try controllerData.DataArray. And for displaying try controllerData.DataArray.department Commented Feb 24, 2016 at 6:50
  • tried that now,it still doesnt display anything.its not even given an error so i cant figure out whats going wrong Commented Feb 24, 2016 at 6:54
  • 1
    Can your try self.DataArray = data; and for displaying try ng-repeat just for a testing purpose. <div ng-repeat="obj in controllerData.DataArray "> obj.department </div>. Do declare var obj; Commented Feb 24, 2016 at 6:59
  • if you can create a jsFiddle for this, I will fix it for sure Commented Feb 24, 2016 at 6:59
  • try directly like department and total else, as Imcoder pointed out, use ng-repeat for test purpose Commented Feb 24, 2016 at 7:19

1 Answer 1

4

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>
Sign up to request clarification or add additional context in comments.

1 Comment

Did you try this answer?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.