Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HTML:

HTML
</head>
<body>
    <div ng-controller="tableController">

        <table ng-table="usersTable" class="table table-striped">
            <tr ng-repeat="user in data">
                <td data-title="'Id'">
                    {{user.id}}
                </td>
                <td data-title="'First Name'">
                    {{user.first_name}}
                </td>
                <td data-title="'Last Name'">
                    {{user.last_name}}
                </td>
                <td data-title="'e-mail'">
                    {{user.email}}
                </td>
                <td data-title="'Country'">
                    {{user.country}}
                </td>
                <td data-title="'IP'">
                    {{user.ip_address}}
                </td>
            </tr>
        </table>

    </div>
</body>
</html>


JAVA:

JavaScript
angular.module('ngTableTutorial', ['ngTable'])
        .controller('tableController', function ($scope, $filter, ngTableParams) {

            $scope.users = [{ "id": 1, "first_name": "Philip", "last_name": "Kim", "email": "pkim0@mediafire.com", "country": "Indonesia", "ip_address": "29.107.35.8" },
                        { "id": 2, "first_name": "Judith", "last_name": "Austin", "email": "jaustin1@mapquest.com", "country": "China", "ip_address": "173.65.94.30" },
                         { "id": 3, "first_name": "Judith", "last_name": "Austin", "email": "jaustin1@mapquest.com", "country": "China", "ip_address": "173.65.94.30" },                            
{ "id": 8, "first_name": "Judith", "last_name": "Austin", "email": "jaustin1@mapquest.com", "country": "China", "ip_address": "173.65.94.30" },
                               { "id": 9, "first_name": "Judith", "last_name": "Austin", "email": "jaustin1@mapquest.com", "country": "China", "ip_address": "173.65.94.30" },
                                                { "id": 16, "first_name": "Andrea", "last_name": "Greene", "email": "agreene4@fda.gov", "country": "Russia", "ip_address": "128.72.13.52" }];

            $scope.usersTable = new ngTableParams({
                page: 1,
                count: 10
            }, {
                total: $scope.users.length,
                getData: function ($defer, params) {
                    $scope.data = $scope.users.slice((params.page() - 1) * params.count(), params.page() * params.count());
                    $defer.resolve($scope.data);
                }
            });
        });


CONTROLLER:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Magazyn.Controllers
{
    public class BazaController : Controller
    {
        // GET: Baza
        public ActionResult Index()
        {
            return View();
        }
    }
}


I need to use simple LocalDB or SQLExpress database file instead $scope.users.. static table.??? Please for Help. Thanx:)
Posted

1 solution

Hello,

If you are using MVC, then you might be aware of the Entity Framework concepts. So use EF Code First or the Database first approaches to connect to a database. Add your required tables. For example User table. Then use the $http core Angular Service to get/fetch the data. Like below
appModule.controllers('getUsersController', function($scope,$http){
      $http.get('GET USERS URL').then(
           funtion (response) {
                //Binds your response here.
             }
        )
});

Hope this helps.
Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900