Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

New to Angular - How do I define the table columns

I had this question after viewing New to Angular (read tutorial) - How do I bind to this table?.

I got some of the Angular pieces together by using the post above. I need help with a couple of things I will post my other question in another thread

1. Table columns


This is what I have now

1. Model In here I have several fields but I have this list

public List<Contacts> contacts {get; set;}

Open in new window


and "Contacts" looks like this (it has more fields). This is  table generated by edmx, I think

 public string districtName {get;set;}
 public string firstName {get;set;}
 public string Email {get;set;}
....

Open in new window


Now, I have the table like this but I don't think this is correct

 <div ng-controller ="contactController" st-table ="contactDetails">
    <thead>
              <tr>
                 <th st-sort="firstName" class="sortable"> First Name </th>
                    .....
            </tr>
  </thead>
<tbody>
  <tr ng-repeat="row in contactDetails" ng-class="...">
     <td>{row.firstName}} </td>
</tr>
</tbody>
</div>

Open in new window


But I don't think {row.firstName}}  is correct. "contacts" in the model is a list of Contacts. So, how do I get to the properties of "Contacts"?
Avatar of Moussa Mokhtari
Moussa Mokhtari

In your contactController you should have contactDetails have the list of contacts "[]" that you got from your server

<div ng-controller ="contactController" >

	<table st-table="contactDetails">
	 	<tr ng-repeat="row in contactDetails">
	 		<td>{{row.firstName}} </td>
	 	</tr>
	</table>

Open in new window

</div>
Avatar of Camillia

ASKER

ah, let me look. I'll post back. I don't I have that.
I just got started on the controller. So, I need to add
$scope.Contacts = [];

This is how the controller looks like

User generated image
ASKER CERTIFIED SOLUTION
Avatar of Moussa Mokhtari
Moussa Mokhtari

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ah, let me add that. I have another question. I want to make sure I have the different pieces together and get the $scope right. I'll open another question.