I am new to Angular.js . Trying to print total number of the rows but can't access the ng-init
variable (ct). last span tag is not showing the value of {{ct}}. Did I miss anything ?
<div id="test-area" ng-controller="mycontroller" >
<input type="number" step="1" max="5" min="1" ng-model="count" style="width:50px;"/>
<input type="number" step="1" max="4" min="0" ng-model="indexFrom" style="width:50px;"/>
<table class="tab1">
<thead>
<th>Name</th> <th>Id</th> <th>Address</th> <th>Number</th>
<th>Date</th>
</thead>
<tr ng-repeat="user in users | limitTo:count:indexFrom " ng-init="parent=user;$parent.ct=$index">
<td>{{user.name | uppercase}}</td>
<td> {{user.id | number }}</td>
<td>{{user.address |lowercase}}</td>
<td ng-bind="parent.marks[0].it |currency:'$'">
</td>
<td class="ng-bind:user.bs | date:'dd/MM/yyyy'">
</td>
</tr>
</table>
<br/>
<span class="gray">Total Row Number : {{ct}} | From {{indexFrom}} to {{indexFrom+count}} </span>
<br/>
</div>
js :
(function(){
var app=angular.module("Myapp",[]);
var mycontrol=function($scope){
$scope.users=users;
$scope.increment=increment;
$scope.change=change;
$scope.count=3;
$scope.indexFrom=0;
}
//marks increment
var increment=function(marks){
marks.it+=1;
}
//id increment
var change=function(num){
num.id=Number(num.id)+1;
}
var users=[{
name:"Nihar",
id:"123",
address:"New Town",
bs:new Date("April 30 1993"),
marks:[{it:90},{it:88},{it:97}]
},{
name:"Nilanjan",
id:"194",
address:"Baguiati",
bs:new Date("July 20 1993"),
marks:[{it:94},{it:65},{it:82}]
},{
name:"Raktim",
id:"129",
address:"Tegharia",
bs:new Date("September 17 1993"),
marks:[{it:97},{it:81},{it:79}]
},{
name:"Kaushik",
id:"126",
address:"Howrah",
bs:new Date("October 10 1992"),
marks:[{it:81},{it:89},{it:78}]
},{
name:"Abhishek",
id:"287",
address:"Dum Dum",
bs:new Date("December 25 1994"),
marks:[{it:91},{it:68},{it:87}]
}];
app.controller("mycontroller",mycontrol)
}());