Better way of doing this <tr> ng-repeat? - angularjs

I am generating from the database a sidebar, based on types of books. For each type, I generate a tab to show listings of books in that type. It works well for other cases with less records, but I am getting a delay of some seconds in this case. Any ideas on how to improve performance of this?
Layout:
#* Sidebar *#
<div class="col-sm-3" ng-if="ShowSidebar" ngCloak>
<ul class="list-group sidebar-nav-v1" id="sidebar-nav">
#* Books *#
<li class="list-group-item list-toggle">
<a data-toggle="collapse" data-parent="#sidebar-nav" href="#collapse0">
<i class="fa fa-sort-alpha-asc"> </i> Books
</a>
<ul id="collapse0" class="collapse1 accordion-body collapse">
<li ng-repeat="bookTopic in ListBookTopics" style="text-align:justify">{{bookTopic.topic_en}}</li>
</ul>
</li> #* End of Books *#
#* Series *#
<li class="list-group-item list-toggle">
<a data-toggle="collapse" data-parent="#sidebar-nav" href="#collapse1">
<i class="fa fa-sort-alpha-asc"> </i> Series (Collections)
</a>
<ul id="collapse1" class="collapse">
<li ng-repeat="seriesTopic in ListSeriesTopics" style="text-align:justify">{{seriesTopic.topic_en}}</li>
</ul>
</li> #* End of Series *#
</ul>
</div> #* End of Sidebar v2*#
#* Main Area *#
<div class="col-sm-9" ng-if="ShowMainArea" ngCloak>
<div class="tab-v3">
<div class="tab-content">
#* Generate Books Tabs to list books by type *#
<div class="tab-pane fade in" id="{{booksTopic.id}}" ng-repeat="booksTopic in ListBookTopics" ng-cloak>
<div class="table-search-v1 panel panel-dark margin-bottom-50">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-book"></i> {{booksTopic.topic_en}} </h3>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-search"></i></div>
<input type="text" class="form-control" placeholder="Search..." ng-model="searchParamBooksTopics">
</div>
</div>
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="center" rowspan="2">Title</th>
<th class="center" rowspan="2">Author</th>
<th class="center" rowspan="1">Number</th>
<th class="center" rowspan="1">Type</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in ListBooksInBooks | filter: { title: searchParamBooksTopics }" ng-if="row.title.length>1 && row.topics_id == booksTopic.id">
<td style="text-align:justify;"> {{row.title}}</td>
<td>{{row.author}}</td>
<td class="center">{{row.number}}</td>
<td class="center">{{row.topics_id}}</td>
</tr>
</tbody>
</table>
</div> #* End of table-responsive *#
</div> #* End of table-search-v1 panel panel-dark margin-bottom-50 *#
</div> #* End of Tab Content 1 - Books *#
</div> #* End of tab-content *#
</div> #* End of tab-v3 *#
</div> #* End of col-sm-9 - Main Area *#
Angular - Used Lists:
$scope.ListBookTopics = #Html.Raw( new JavaScriptSerializer().Serialize( Model.ListBookTopics ) )
$scope.ListBooksInBooks = #Html.Raw( new JavaScriptSerializer().Serialize( Model.ListBooksInBooks ) );
The line that is causing the delay is this one:
<tr ng-repeat="row in ListBooksInBooks | filter: { title: searchParamBooksTopics }" ng-if="row.title.length>1 && row.topics_id == booksTopic.id">
Any faster way of looping the list of books and getting all books of that type?

Related

dynamically change the value of the ng-init with ng-repeat simultaneously with id

<div class="rightside-table-container">
<div ng-repeat="d in organiser" ng-init="get_org_dtls(d.ref_No)"
id="cr-upper-div">
<div class="row" id="cr-upperdiv-firstrow">
<table class="table" id="cr-tableclass">
<tbody id="upperdiv-table-tbody">
<a href="#">
<tr id="cr-upperdiv-firsttr">
<td colspan="3">{{d.organiser_Name}}</td>
</tr>
</a>
<tr id="cr-upperdiv-secondtr">
<td data-toggle="modal" data-target="#myModal"
data-toggle="tooltip" title="Billed" id="cr-upperdiv-firsttd"><span>8</span></td>
<td data-toggle="modal" data-target="#myModal"
data-toggle="tooltip" title="On Hold" id="cr-upperdiv-secondtd">7</td>
<td data-toggle="modal" data-target="#myModal"
data-toggle="tooltip" title="Void Bill" id="cr-upperdiv-thirdtd">2</td>
</tr>
<tr id="cr-upperdiv-thirdtr">
<td ng-repeat="od in organiser_dtls_data"
ng-if="od.organiser_Code==d.ref_No"><md-button
ng-click="showCashregister($event)"
class="md-raised md-primary org_dtls_btn">
<div class="organiser_dtls_container md-ink-ripple">
<div class="org_head">
<p class="org_title">{{od.organiser_Details_Name}}</p>
</div>
<div class="org_mid">
<div class="org_loc">
<p class="org_loc_title">{{od.organiserLocation.organiser_Location_Name}}</p>
</div>
<div class="org_capacity">
<p class="org_cap_title">{{od.organiser_Capacity}}</p>
</div>
</div>
<div class="org_status">
<p class="org_status_title">Reserved</p>
</div>
</div>
</md-button></td>
</tr>
</tbody>
</table>
</div>
<div class="row" id="cr-upperdiv-secondrow">
<div class="merge" id="cr-mergeclass">
<div class="merge-icon">
<img class="Centered" src="/images/mergew.png" height="20px"
width="20px" />
</div>
<div class="merge-text">
<span>Merge</span>
</div>
</div>
<div class="split" id="cr-splitclass">
<div class="merge-icon">
<img class="Centered" src="/images/splitw.png" height="20px"
width="20px" />
</div>
<div class="merge-text">
<span>Split</span>
</div>
</div>
</div>
</div>
</div>

angular js server side pagination with search without using pagination

My Get search Api looks like
"http://localhost:3000/api/driver/search/" + searchText + "/" + pagesize + "/" + page;
Functionality is like if i search using a string, it should result table with prev and next button.
For search, I need to pass page size and page number to search method.
Below is y Html looks like
<div class="input-group col-md-4 col-md-offset-8" align="center">
<input class="form-control" type="search" ng-model="searchText" placeholder="Search" />
<button class="input-group-addon" ng-click="search(searchText)">
<span class="glyphicon glyphicon-search"></span>
</button>
</div>
<br /><br />
<table class="table table-condensed table-hover table-striped table-bordered" ng-show="showtable">
<thead>
<tr>
<th class="label label-info visible-lg"><h5 class="text-capitalize">Driver ID</h5></th>
<th class="label label-info visible-lg"><h5 class="text-capitalize">Driver Name</h5></th>
<th class="label label-info visible-lg"><h5 class="text-capitalize">Contact Number</h5></th>
<th class="label label-info visible-lg"><h5 class="text-capitalize">Driver Email</h5></th>
<th class="label label-info visible-lg"><h5 class="text-capitalize">ShiftType</h5></th>
<th class="label label-info visible-lg"><h5 class="text-capitalize">Action</h5></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="driver in drivers">
<td>
<div ng-if="driver.editing"> <div ng-class="name" align="center"> {{driver.driverId}}</div> </div>
<div ng-if="driver.saving">
<div align="center">
{{driver.driverId}} </div>
</div>
</td>
<td>
<div ng-if="driver.editing"> <div ng-class="name" align="center"> {{driver.driverName}}</div> </div>
<div ng-if="driver.saving">
<div align="center"><input type="text" ng-model="driver.driverName" required /></div>
</div>
</td>
<td>
<div ng-if="driver.editing"><div align="center"> {{driver.contactNumber}}</div></div>
<div ng-if="driver.saving">
<div align="center"><input type="text" ng-model="driver.contactNumber" required /></div>
</div>
</td>
<td>
<div ng-if="driver.editing"><div align="center"> {{driver.email}}</div></div>
<div ng-if="driver.saving">
<div align="center"><input type="text" ng-model="driver.email" required /></div>
</div>
</td>
<td>
<div ng-if="driver.editing"><div align="center"> {{driver.shiftType}}</div></div>
<div ng-if="driver.saving">
<div align="center"><input type="text" ng-model="driver.shiftType" required /></div>
</div>
</td>
<td align="center">
<div ng-if="driver.editing">
<button ng-click="edit(driver, driver.driverId)" class="edit btn-info">
<i align="center" class="glyphicon glyphicon-edit"></i>
</button>
</div>
<div ng-if="driver.saving" class="btn-group">
<button align="center" ng-click="save(driver,driver.driverId)" class="glyphicon-save btn-group-sm btn-success">
<i class="glyphicon glyphicon-floppy-save"></i>
</button>
<button align="center" ng-click="cancel(driver,driver.driverId)" class="glyphicon-remove btn-group-sm btn-warning">
<i class="glyphicon glyphicon-remove"></i>
</button>
</div>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="9">
<div align="right">
<ul class="pagination">
<li ng-class="{disabled: currentPage == 0}">
<< prev
</li>
<li ng-repeat="n in range(drivers.length)" ng-class="{active: n == currentPage}" ng-click="setPage()">
1
</li>
<li ng-class="{disabled: currentPage == drivers.length - 1}">
Next »
</li>
</ul>
</div>
</td>
</tr>
</tfoot>
I am not sure how to proceed. How to input these values. Any suggestions greatly helpful.

How do I show different modal data on each subjects displayed?

How do I show different modal data on each subjects displayed?
My Problem: Showing same modal data on each subjects displayed.
My blade view
#section('content')
<!-- Main content -->
<section class="content" style="background-color:#fff; padding-bottom:50px;" id="subjects">
<div class="subjects-content">
<h3>List of Subjects</h3>
<div class="box-body box-self-evaluation" v-show="subjects.length > 0">
<table id="example2" class="table table-hover table-striped sortable">
<thead>
<tr>
<th>Subject Area</th>
<th>Course Title</th>
<th>Failed</th>
<th>View more</th>
</tr>
</thead>
#foreach ($all_subjects as $subject)
<tbody>
<tr>
<td>
<span> {{ $subject->subject_code }}</span>
</td>
<td>
<span> {{ $subject->description }} </span>
</td>
<td>
<span> {{ $subject->grade()->where('grade','F')->count() }} </span>
</td>
<td><span> <div class="btn btn-crimson btn-inline-block" data-toggle="modal" data-target="#myModal">View more info</div> </span></td>
</tr>
</tbody>
#endforeach
</table>
</div>
<div class="confirmation-buttons-self-evaluation">
<div class="btn btn-blueviolet btn-inline-block btn-create">Go to Self-Evaluation Page</div>
</div>
#foreach ($all_subjects as $subject)
<!--MODAL -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- MODAL content -->
<div class="modal-content" style="width:70%; margin:0 auto; margin-top:100px; max-height: calc(100vh - 210px); overflow-y: auto;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Subject: {{ $subject->subject_code }}</h4>
</div>
<div class="modal-body" style="padding-top:0">
<center>
<table class="table">
<thead>
<th colspan="3" style="text-align:center">List of Disgraceful Students</th>
</thead>
<thead class="failed-header">
<th>Section: <span style="color:#000"> CS <!-- SECTION --> </span></th>
<th>Professor: <span style="color:#000"> John Doe <!-- PROF --> </span></th>
<th>Failed: <span style="color:#000"> 2 <!-- NUMBER OF FAILED SA SECTION --> </span></th>
</thead>
<tbody>
<tr>
<td><img src="{{ asset('dist/img/default.png')}}" class="img-square" alt="User Image" style="height:50px; width:50px"></td>
<td style="padding-top: 20px" colspan="2"> John Jashuel </td>
</tr>
<tr>
<td><img src="{{ asset('dist/img/default.png')}}" class="img-square" alt="User Image" style="height:50px; width:50px"></td>
<td style="padding-top: 20px" colspan="2"> John Caezar </td>
</tr>
</tbody>
</center>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
<!-- /. modal content-->
#endforeach
</section>
#endsection
what is wrong with my code?
how do I solve this?
help me please...
any suggestion or comments are well appreciated thank you!
try to change
data-target="#myModal"
to
data-target="#{{$subject->id}}"
and id in <--modal-->
From
id="myModal"
to
id="{{$subject->id}}"

How to divide rows to two table with angularjs

how to divide rows to two tables with angularjs
<tr ng-repeat="field in node.fields track by $index" ui-tree-node="" class="ng-scope angular-ui-tree-node" collapsed="false" ng-if="$even">
I have tried this but it is not working for drag and drop
<tr data-ng-repeat="element in awesomeThings">
<div ng-if="$even">
<td class="even">
<a href="#">
{{element}}
</a>
</td>
</div>
<div ng-if="$odd">
<td class="odd">
<a href="#">
{{element}}
</a>
</td>
</div>
</tr>

Dynamic JSON handling in angularJS

I've got two JSON arrays, one for headers and the other for data. I'm handling the headers, and I'm trying to display the data with respect to those headers using nested ng-repeat, but it results in empty rows.
The JSON arrays and the html code for displaying the data are pasted below.
Please help me.
$scope.data=[{'first_name':'ruth','last_name':'vick','email':'ruthvick#gmail.com','isMarried':'no','nick_name':'ruthu'},{'first_name':'rahul','last_name':'kumar','email':'rahul#gmail.com','isMarried':'no','nick_name':'rahul'},{'first_name':'vicky','last_name':'gupta','email':'vicky#gmail.com','isMarried':'no','nick_name':'vicky'}]
$scope.headerAll=[{'field':'first_name', 'displayName':'First name','type':'required'},{'field':'last_name', 'displayName':'Last Name','type':'required'},{'field':'email', 'displayName':'Email','type':'required'},{'field':'isMarried', 'displayName':'marital Status','type':'optional'},{'field':'nick_name', 'displayName':'Nick Name','type':'optional'}]
<div>
<table class="table table-bordered table-hover">
<thead class="wrapper">
<tr>
<th ng-repeat="data in header">
<div class="col-md-9">{{data.displayName}}</div>
<div class="col-md-1">
<button href="" ng-click="deleteColumn(data.field,$index)"><span class=" glyphicon glyphicon-trash pull-right"> </span></button>
</div>
<div class="dropdown col-md-1" >
<button class="glyphicon glyphicon-pencil dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" ng-click = "toPoint($index);">
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1" ng-repeat="optionalHeader in optional">
<li role="presentation" ng-repeat="dataEdit in headerAll"><a role="menuitem" tabindex="-1" href="" ng-click="editColumn(data.field,dataEdit.field,$index)">{{dataEdit.displayName}}</a></li>
</ul>
</div>
</th>
<th><div class="dropdown" >
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
Add Columns
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1" ng-repeat="optionalHeader in optional">
<li role="presentation" ng-repeat="optionalHeader in optional"><a role="menuitem" tabindex="-1" href="" ng-click="addColumn(optionalHeader.field)">{{optionalHeader.displayName}}</a></li>
</ul>
</div>
</th>
</tr>
</thead>
<tbody >
<tr class="active" ng-repeat="row in data">
<td ng-repeat="fields in headerAll">
{{row.fields.field}}
</td>
</tr>
</tbody>
</table>
</div>
Here, row.fields.field is creating empty rows.
Try to access with braces and not the dot operator.
data:
<div ng-repeat="obj in data">
{{ obj["first_name"]}}
{{ obj["last_name"]}}
</div>
header
<div ng-repeat="obj in headerAll">
{{ obj["field"]}}
{{ obj["displayname"]}}
</div>

Resources