I am trying to use infinite scroll in a angular UI modal and the modal is defined in ng-template as shown below
<script type="text/ng-template" id="someID" >
<div infinite-scroll="loadMoreEmployees()" infinite-scroll-distance="1">
<div class="modal-header">
<div class="vertical-margin row">
<div class="col-lg-12">
<h2 class="help-block">Departments assign</h2>
</div>
</div>
</div>
<div class="modal-body">
<div class="content-container">
<div class="col-lg-12 col-md-12 simple-data-table-content">
<table data-ng-if="vm.employees!=null || vm.employees.length!=0" class="table table-condensed text-center clear-bottom">
<tbody>
<tr>
<th>Employee No</th>
<th>Employee Name</th>
<th>Email</th>
<th data-ng-repeat="DeptType in vm.DeptTypes track by $index">{{DeptType.name}}</th>
<th></th>
</tr>
<tr data-ng-if="vm.employees==null || vm.employees.length==0"><td colspan="{{vm.DeptTypes.length + 4}}"></td></tr>
<tr data-ng-repeat="employee in vm.employees | limitTo:vm.loadEmployeeLimitCount" data-ng-if="vm.employees!=null && vm.employees.length > 0">
<td class="">{{employee.employeeNumber}}</td>
<td class="">{{employee.name}}</td>
<td class="">{{employee.email}}</td>
<td class="" data-ng-repeat="DeptType in vm.DeptTypes">
<input type="text" only-digits data-ng-model="employee.DeptSummary[DeptType.id]" style="width:50px;" min="1" />
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
But infinite scroll as does not respond to scroll action, please point out where I am wrong.
Related
I m using angularjs to retrieve my data in my spring web app project. it is able to retrieve and display the data in all places i have passed it using {{ }} but in my form-action link it is not able to read the value passed . what is wrong with the syntax?
<div class="container text-center" ng-app="myApp" ng-controller="myCtrl">
<div ng-repeat="product in Data" >
<div class=col-lg-5>
<center>
<img src="<c:url value='/resource/image/{{product.name}}.jpg'/>" />
</center>
</div>
<div class=col-lg-7>
<table class="table table-striped">
<tr>
<h1>{{product.name}}</h1>
</tr>
<tr>
<th>Description</th>
<td>{{product.description}}</td>
</tr>
<tr>
<th>Category</th>
<td>{{product.category}}</td>
</tr>
<tr>
<th>Price</th>
<td>Rs.{{product.price}}</td>
</tr>
^
till here it displays the data using angular js
</table>
</div>
<form:form method="POST" modelAttribute="cart" action="${pageContext.request.contextPath}/user/addtocart?productId={{product.id}}">
^
here it doesnt read the data passed using angularjs
<sec:authorize access="hasRole('ROLE_USER')">
<input type="submit" class="btn btn-info btn-lg" value="Add to Cart" />
</sec:authorize>
</form:form>
Change your HTML to below way,because your ng-controller <div> tag ended before the form as the angular scope is restricted to that </div> tag itself your {{}} expression in action is not evaluated.
<div class="container text-center" ng-app="myApp" ng-controller="myCtrl">
<div ng-repeat="product in Data">
<div class=col-lg-5>
<center>
<img src="<c:url value='/resource/image/{{product.name}}.jpg'/>" />
</center>
</div>
<div class=col-lg-7>
<table class="table table-striped">
<tr>
<h1>{{product.name}}</h1>
</tr>
<tr>
<th>Description</th>
<td>{{product.description}}</td>
</tr>
<tr>
<th>Category</th>
<td>{{product.category}}</td>
</tr>
<tr>
<th>Price</th>
<td>Rs.{{product.price}}</td>
</tr>
</table>
<form:form method="POST" modelAttribute="cart" action="${pageContext.request.contextPath}/user/addtocart?productId={{product.id}}">
<sec:authorize access="hasRole('ROLE_USER')">
<input type="submit" class="btn btn-info btn-lg" value="Add to Cart" />
</sec:authorize>
</form:form>
</div>
</div>
</div>
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}}"
I had a view with multiple groups of radio buttons that worked great, but was using a really old version of AngularJS (v1.0.2 as I was playing with an existing fiddle I had found on the net)
Example using AngularJS v1.0.2
As soon as I upgraded to v1.4.8, it stopped working as expected - i.e. only the last group of radio buttons in each panel have their applicable radio button checked while all others groups had no radio buttons checked.
Example with newer version of AngularJS
Has anyone got an idea as to what I may be doing wrong? Any help would be much appreciated. Below is the html involved
<body ng-controller="Channels" class="container-fluid">
<div ng-if="sections===null">
Loading...
</div>
<div class="panel-group" id="accordion1" ng-if="sections!==null">
<div class="panel panel-default" ng-repeat="item in sections | orderBy: 'resourceCode'">
<div class="panel-heading">
<div class="glyphicon glyphicon-plus-sign text-primary" style="float: left; margin-right: 5px;"></div>
<a data-toggle="collapse" data-parent="#accordion1" href="#{{getID(item)}}">
<span class="panel-title" ng-bind="item.resourceCode"></span>
</a>
</div>
<div id="{{getID(item)}}" class="panel-collapse collapse" ng-class="{'in': isActiveSection(item)}">
<table class="table">
<thead>
<th class="col-sm-6">Name</th>
<th class="col-sm-2 text-center">Read</th>
<th class="col-sm-2 text-center">ReadWrite</th>
<th class="col-sm-2 text-center">None</th>
</thead>
<tr ng-repeat="subitem in item.subPrivilegeModels | orderBy: 'resourceCode'">
<td class="col-sm-6"><span ng-bind="subitem.resourceCode"></span></td>
<td class="col-sm-2 text-center">
<input type="radio" name="access_{{$parent.$index}}_{{$index}}" ng-model="subitem.access" ng-value="'READ'"/>
</td>
<td class="col-sm-2 text-center">
<input type="radio" name="access_{{$parent.$index}}_{{$index}}" ng-model="subitem.access" ng-value="'READWRITE'"/>
</td>
<td class="col-sm-2 text-center">
<input type="radio" name="access_{{$parent.$index}}_{{$index}}" ng-model="subitem.access" ng-value="'NONE'"/>
</td>
</tr>
<tbody>
</table>
</div>
</div>
</div>
not to worry...managed to solve it using a form element between the sections and changed the naming of the radiobuttons
<body ng-controller="Channels" class="container-fluid">
<div class="panel-group" id="accordion1" ng-if="sections!==null">
<div class="panel panel-default" ng-repeat="item in sections | orderBy: 'resourceCode'">
<div class="panel-heading">
<div class="glyphicon glyphicon-plus-sign text-primary" style="float: left; margin-right: 5px;"></div>
<a data-toggle="collapse" data-parent="#accordion1" href="#{{getID(item)}}">
<span class="panel-title" ng-bind="item.resourceCode"></span>
</a>
</div>
<div id="{{getID(item)}}" class="panel-collapse collapse" ng-class="{'in': isActiveSection(item)}">
<form>
<table class="table">
<thead>
<th class="col-sm-6">Name</th>
<th class="col-sm-2 text-center">Read</th>
<th class="col-sm-2 text-center">ReadWrite</th>
<th class="col-sm-2 text-center">None</th>
</thead>
<tr ng-repeat="subitem in item.subPrivilegeModels | orderBy: 'resourceCode'">
<td class="col-sm-6"><span ng-bind="subitem.resourceCode"></span></td>
<td class="col-sm-2 text-center">
<input type="radio" name="access_{{$index}}" ng-model="subitem.access" ng-value="'READ'"/>
</td>
<td class="col-sm-2 text-center">
<input type="radio" name="access_{{$index}}" ng-model="subitem.access" ng-value="'READWRITE'"/>
</td>
<td class="col-sm-2 text-center">
<input type="radio" name="access_{{$index}}" ng-model="subitem.access" ng-value="'NONE'"/>
</td>
</tr>
<tbody>
</table>
</form>
</div>
</div>
</div>
i'm developing for the first time with Angular JS and i created the following bootstrap modal in which there is a table with some content and inputs. Here is the code:
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4>User Menu</h4>
</div>
<div class="modal-body">
<div class="tablecontainer">
<table class="table table-striped table-hover table-condensed">
<colgroup>
<col class="col-md-1">
<col class="col-md-2">
<col class="col-md-2">
<col class="col-md-3">
<col class="col-md-2">
<col class="col-md-2">
</colgroup>
<thead>
<tr>
<th> </th>
<th>Firstname</th>
<th>Lastname</th>
<th>Address</th>
<th>Attachment</th>
<th>Group</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in users">
<td>
<input type="checkbox" value="" ng-model="ctrl.checked[$index]" ng-disabled="ctrl.fileupload!==undefined" ng-change="ctrl.checkBox($index)" />
</td>
<td>{{user.firstname}}</td>
<td>
<select class="form-control" ng-model="user.selectedAddress" ng-change="ctrl.checked[$index] = user.selectedAddress.destAddress" ng-options="o as o.destName for o in user.addresses"></select>
</td>
<td>{{user.selectedAddress.destAddress}}</td>
<td><input type = "text" class="customPart"
ng-model="ctrl.customText[$index]" /></td>
</tr>
</tbody>
</table>
</div>
[...]
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default btn-flat" data-dismiss="modal">Close</button>
</div>
</div>
</div>
What is the angular way of clearing bootstrap modal to reset the user inputs?
You don't reset the UI to have a fresh model, you wan't to do the contrary. You need to reset the model, then your UI will be reset.
You can write a function that will reset your users array. For example:
function reset() {
for(var i = 0; i < users.length; i++) {
users[i].selectedAddress = null;
}
}
I have an AgularJS search using a filter, which works. I now want the filter to only show results that match the filter.
So, I want the initial data load to not show, if my typed in filter matches, then show the results.
Here is my code so far:
<div class="row">
<div class="large-12 columns">
<div ng-app>
<div ng-controller="CashTransController">
<input type="text" ng-model="search.$">
<br />
<div><strong>Filter Results</strong></div>
<br />
<div class="row"></div>
<br/>
<table border="0" class="items">
<thead>
<tr>
<th>Purchaser</th>
<th>Redemption Code</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in items | filter:search">
<td>{{item.firstname}} {{item.lastname}}</td>
<td valign="top"><h3>{{item.redemption_code}}</h3></td>
<td><h3>{{item.creation_date}}</h3></td>
</tr>
</tbody>
</table>
<br />
</div>
</div>
</div>
</div>
You could simply add a ng-show to the table items.
I don't know why you called your search model search.$ and not just search.
Try this code. It will only show the results if you typed something into the input:
<div class="row">
<div class="large-12 columns">
<input type="text" ng-model="search">
<br/>
<div><strong>Filter Results</strong></div>
<br/>
<div class="row">
<p>{{search}}</p>
</div>
<br/>
<table border="0" class="items">
<thead>
<tr>
<th>Purchaser</th>
<th>Redemption Code</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr ng-show="search" ng-repeat="item in items | filter:search">
<td>{{item.firstname}} {{item.lastname}}</td>
<td valign="top"><h3>{{item.redemption_code}}</h3></td>
<td><h3>{{item.creation_date}}</h3></td>
</tr>
</tbody>
</table>
<br/>
</div>
</div>