Angular.js를 처음 사용합니다. 전체 행 수를 인쇄하려고 시도했지만 ng-init
변수 (ct)에 액세스 할 수 없습니다. 마지막 범위 태그가 {{ct}}의 값을 표시하지 않습니다. 내가 놓친 게 있니?은 ng-init 값에 액세스 할 수 없습니다.
<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:"baguiaty",
bs:new Date("October 20 1993"),
marks:[{it:94},{it:65},{it:82}]
},{
name:"raktim",
id:"129",
address:"new town",
bs:new Date("November 20 1994"),
marks:[{it:97},{it:81},{it:79}]
},{
name:"kaushik",
id:"126",
address:"Howrah",
bs:new Date("November 20 1994"),
marks:[{it:81},{it:89},{it:78}]
},{
name:"Malhotra",
id:"287",
address:"dumDum",
bs:new Date("july 23 1994"),
marks:[{it:91},{it:68},{it:87}]
}];
app.controller("mycontroller",mycontrol)
}());
우리는 JS를 볼 수 있습니까? –
Danny의 답을 더 넓히기 위해 : 우리가 코드의 가장 중요한 부분을 우리에게 보여주지 않았기 때문에, 무엇이 잘못 되었는가에 대한 단서가 있습니다. 당신은 자바 스크립트 질문을 가지고 있지만, 우리는 자바 스크립트를 보여주지 않습니다. –
확실히, 나는 The Js를 추가 할 것이다 –