I need one help.I need to check if the array has no value and display one message there using Angular.js.I am explaining my code below.
<table class="table table-bordered table-striped table-hover" id="dataTable">
<thead>
<tr>
<th>Sl. No</th>
<th>Date</th>
<th>
Info(Academic Year,Section,Subject,Semester)
</th>
<th>
Unit Name
</th>
<th>
Lecture Plan
</th>
<th>Action</th>
</tr>
</thead>
<div ng-if="viewIncompletePlanData.length>0">
<tbody id="detailsstockid">
<tr ng-repeat="p in viewIncompletePlanData">
<td>{{$index+1}}</td>
<td>{{p.date}}</td>
<td>{{p.session}},{{p.section_name}},{{p.subject_name}},{{p.semester}}</td>
<td>{{p.unit_name}}</td>
<td>{{p.plan}}</td>
<td>
<a >
<input type='button' class='btn btn-xs btn-success' value='Update' ng-click="">
</a>
</td>
</tr>
</tbody>
</div>
<div ng-if="viewIncompletePlanData.length==0">
<tr>
<center><p><b>No Record Matched</b></p></center>
</tr>
</div>
</table>
In the above code i need when viewIncompletePlanData has no value it will display message there No record found Otherwise display the array result.Please help me.
You can check the length of the array. If the length > 0 then show the records in table else if array is undefined or length === 0 then show No Record Found in the first row of table.
<table>
<tbody id="detailsstockid">
<tr ng-repeat="p in viewIncompletePlanData" ng-if="viewIncompletePlanData.length>0">
<td>{{$index+1}}</td>
<td>{{p.date}}</td>
<td>{{p.session}},{{p.section_name}},{{p.subject_name}},{{p.semester}}</td>
<td>{{p.unit_name}}</td>
<td>{{p.plan}}</td>
<td>
<a>
<input type='button' class='btn btn-xs btn-success' value='Update' ng-click="">
</a>
</td>
</tr>
<tr ng-if="viewIncompletePlanData== null || viewIncompletePlanData.length === 0">
<td>
No Record Found
</td>
</tr>
</tbody>
</table>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With