Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to bind some data that is coming from ms sql database to a single page angular. apparently everything is working fine and I can see the data in json format in network response of the browser but the problem is data cannot bind to ng-repeat tag in html file.

here is my html file

<div class="row">
<h1>Users</h1>
<div class="span10">
    <table class="table table-condenced table-hover">
        <tr>
            <th>User</th>
            <th>user firstname</th>
            <th>user lastname</th>
        </tr>
        <tr ng-repeat="user in users">
            <th>{{user.UserID}}</th>
            <th>{{user.Lastname}}</th>
            <th>{{user.Firstname}}</th>
        </tr>
    </table>
</div>

here is my model

using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Formatting;
using System.Web;
using System.Web.Helpers;
using System.Web.Http.Controllers;
using System.Web.Mvc;

namespace Angular4DotNetMVC.Models
{
    public WoUser[] GetUsers()
    {
        MyScreensEntities xEntity = new MyScreensEntities();
        List<User> xList = new List<User>();
        List<WoUser> userList = new List<WoUser>();

        xList = (from x in xEntity.Users select x).Take(20).ToList();
        if (xList != null)
        {
            foreach (User obj in xList)
            {
                WoUser yUser = new WoUser();
                yUser.Userid = obj.UserID;
                yUser.Userfirstname = obj.UserFirstname;
                yUser.Userlastname = obj.UserLastname;
                userList.Add(yUser);

            }
        }            
        WoUser[] myArray = userList.ToArray();
        return myArray;
    }
}
}

this is my controller

namespace Angular4DotNetMVC.Controllers
{
public class UserController : ApiController
{
    private RegistrationVmBuilder obj = new RegistrationVmBuilder();

    public WoUser[] Get()
    {
        return obj.GetUsers();
    }
}
}

data response from server in json format

html page that shows ng-binding is empty

browser that shows a empty line for each data binding

share|improve this question

1 Answer 1

up vote 0 down vote accepted

naming problem

try this code instead of your code

<div class="row">
<h1>Users</h1>
<div class="span10">
    <table class="table table-condenced table-hover">
        <tr>
            <th>User</th>
            <th>user firstname</th>
            <th>user lastname</th>
        </tr>
        <tr ng-repeat="user in users">
            <td>{{user.userid}}</td>
            <td>{{user.userfirstname}}</td>
            <td>{{user.userlastname}}</td> 
        </tr>
    </table>
</div>
share|improve this answer
    
thanks man. I did really a silly mistake. –  Nima Mar 16 at 9:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.