CraZyDroiD CraZyDroiD -4 years ago 179
AngularJS Question

creating a table in ionic

I am in need of creating a table in Ionic. I thought of using Ionic grid but could not achieve what I wanted. How can I do this? Here is an image of something similar to what i want:

enter image description here

I can use this but how can I divide the rows like in the picture?

<div class="list">

<div class="item item-divider">
Candy Bars

<a class="item" href="#">



Answer Source

The flexbox grid should do what you want. You're not clear as to what limitation you ran into, so it's hard to address your specifics.

Here's a codepen with a working sample that generates your table with the first couple rows and a header:


<html ng-app="ionicApp">

    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">

    <title>Ionic Template</title>

    <link href="//" rel="stylesheet">
    <script src="//"></script>

  <body ng-controller="MyCtrl as ctrl">
    <ion-header-bar class="bar-stable">
        <h1 class="title">Service Provider Details</h1>
        <div class="row header">
          <div class="col">Utility Company Name</div>
          <div class="col">Service Code</div>
          <div class="col">Pay Limit</div>
          <div class="col">Account Number to Use</div>
          <div class="col"></div>
        <div class="row" ng-repeat="data in">
          <div class="col">{{}}</div>
          <div class="col">{{data.code}}</div>
          <div class="col">LK {{data.limit}}</div>
          <div class="col">{{data.account}}</div>
          <div class="col"><button class="button" ng-click="ctrl.add($index)">Add</button></div>



body {
    cursor: url(''), auto;

.header .col {

.col {
    border: solid 1px grey;
    border-bottom-style: none;
    border-right-style: none;

.col:last-child {
    border-right: solid 1px grey;

.row:last-child .col {
    border-bottom: solid 1px grey;


angular.module('ionicApp', ['ionic'])

.controller('MyCtrl', function($scope) {

    var ctrl = this;

    ctrl.add = add; = [
            name: "AiA",
            code: "AI101",
            limit: 25000,
            account: "Life Insurance"
            name: "Cargills",
            code: "CF001",
            limit: 30000,
            account: "Food City"

    function add(index) {
        window.alert("Added: " + index);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download