redirect to different link based on item pattern inside angularjs ng-repeat - angularjs-ng-repeat

I have a angularjs ng-repeat code block like this:
<tr ng-repeat="i in clinvar | filter: query | orderBy: order: direction | limitTo: totalDisplayed">
<td data-title="CR ID">{{ i.c2 }}</td>
</tr>
i.c2 is an ID, by clicking the ID, it can link to other website, the real project is here:
ID Demo
The problem is the ID come from two database and need redirect to different link based on its pattern. The pattern is based on if it contains a period, the logic is like this:
Logic Demo
I am pretty new to angularjs, hope you can help me how to solve the problem. Thanks~

Something along the lines of this should do the trick:
<tr ng-repeat="i in clinvar | filter: query | orderBy: order: direction | limitTo: totalDisplayed">
<td data-title="CR ID">
{{ i.c2 }}
</td>
</tr>
Plunker: http://embed.plnkr.co/ys6DLt/

Related

Aurelia - Require feature to handle reference tracking of a particular filter result when applying multiple filters?

Have a table with the filtering and sorting like so:
<tbody>
<tr class="row"
repeat.for="repo of repos |
filter:searchField.value:filterGitHubTable |
sort: {propertyName: column.value, direction: direction.value} |
pageData:{currentPage: pageNumber, pageSize:pageSize}">
<td class="col-xs-3">${repo.name}</td>
<td class="col-xs-3">${repo.stargazers_count}</td>
<td class="col-xs-3">${repo.forks_count}</td>
<td class="col-xs-3">${repo.open_issues}</td>
</tr>
</tbody>
In my pager code below its setup as
<pagination model.bind="repos"
page-size.bind="pageSize"
pageclick.delegate="handlePageClick($event)"
pagination-class="pg-bluegrey"></pagination>
How to make the pagination element model bind to the reference of a filter result 'after the sorting' but 'before it does the next filter for pagination data'?
The reason is once have pagination data, I don't have the whole filter result to bind with the pagination element. How would I keeping track of page numbering when applying the filter on the table result?
Here's a little trick you might be able to use here. You can use a hidden HTML element to sort of "hold on" to an intermediate version of your data. Aurelia allows you to attach arbitrary attributes to any element, and by using the ref attribute, we can attach the element itself to our viewmodel. We can then access any data we've attached to this element anywhere we want in our view or viewmodel. Check this out:
<input type="hidden" ref="filteredAndSorted"
data.bind="repos |
filter:searchField.value:filterGitHubTable |
sort: {propertyName: column.value, direction: direction.value}" />
<table>
<tbody>
<tr class="row" repeat.for="filteredAndSorted.data |
pageData:{currentPage: pageNumber, pageSize:pageSize}">
<td class="col-xs-3">${repo.name}</td>
<td class="col-xs-3">${repo.stargazers_count}</td>
<td class="col-xs-3">${repo.forks_count}</td>
<td class="col-xs-3">${repo.open_issues}</td>
</tr>
</tbody>
</table>
<pagination model.bind="filteredAndSorted.data"
page-size.bind="pageSize"
pageclick.delegate="handlePageClick($event)"
pagination-class="pg-bluegrey">
</pagination>
I'm betting this is what will help you. Sorry it took so long to answer, I've been quite busy the last few days doing Aurelia training.

Simple laravel 5 pagination links

In my controller I'm displaying records in a table in my View.
Controller:
$promotion = Promotions::paginate(5);
View:
<tr>
<th>Order</th>
<th>Infomation</th>
<th>Date</th>
<th>Cost</th>
<th>From</th>
</tr>
</thead>
<tbody align="center">
<?php $i = 0;?>
#foreach ( $promotion as $promo)
<?php $i++;?>
<tr>
<td data-title="Order">{{$i}}</td>
<td data-title="Infomation">{{$promo['name']}}</td>
<td data-title="Date">29/10/57</td>
<td data-title="Cost">1.99$</td>
<td data-title="From">K-Bank</td>
</tr>
#endforeach
</tbody>
It works properly when I locate manually to exampleurl/mypage?page=2
All seems well. However, I wanted to create two text buttons to go back and fourth between pages.
How can I set these to navigate the pagination back and fourth:
Previous
Next
EDIT: I don't understand why I'm getting downvoted for this question. No where can I find a tutorial on how to split the back and fourth buttons. How professional can your website be if you're restricted to placing the page links to one spot on the page? seriously...
In Laravel 5 there is a single configuration option for Eloquent models to generate pagination. So, you can use the method:
<?php echo $promotion->render(); ?>
If you want an option only with Previous and Next buttons, you need to use
$promotion = Promotions::simplePaginate(5);
Instead of
$promotion = Promotions::paginate(5);

AngularJS: How to use ng-repeat on a data collection that is hierarchical

I am receiving a collection from server that is hierarchical. ie., I've a list of Study that contains Series. For example I get below object from server.
var studies = [ {studyDescription: 'Study1', series:[
{seriesDescription:'Series1'},
{seriesDescription:'Series2'}
]
}];
'series' is nested within a study.
I am using a HTML table to display this data. And I wanted to flatten the hierarchy while displaying. ie the table should look like:
Study Series
--------------------
Study1 Series1
Study1 Series2 ---> Study1 repeats for each series it contains
I use ng-repeat to iterate the the rows:
<tr ng-repeat="study in studies">
<td>{{studyDescription}}</td>
// HOW to repeat for each series ????
</tr>
How to display such hierarchical data using AngularJS ng-repeat directive? I tried using before , but that did not work. Basically I need multiple for loops to repeat the rows that many time. How to achieve this.
Thanks.
You can use multiple tbody to iterate on the series :
HTML :
<table border=1>
<thead>
<th>Studies</th>
<th>Series</th>
</thead>
<tbody ng-repeat="study in studies">
<tr ng-repeat="series in study.series">
<td>{{study.studyDescription}}</td>
<td>{{series.seriesDescription}}</td>
</tr>
</tbody>
</table>
Here's the JSFiddle :
http://jsfiddle.net/L3MWJ/1/
Tell me if it works for you, still I'm not sure if it will work on all browsers.
Did you try nested ng-repeat ? Try this :
<tr ng-repeat="study in studies">
<td>{{study.studyDescription}}</td>
<td>
<span ng-repeat="serie in study.series"></span>
<p> {{serie.seriesDescription}}</p>
</td>
</tr>

xpath - how to find info

Given this HTML:
<tr class="even" id="district_22">
<td class="name">Virginia Beach City Public Schools</td>
<td class="">Delete</td>
</tr>
<tr class="even" id="district_23">
<td class="name">Virginia City City Public Schools</td>
<td class="">Delete</td>
</tr>
<tr class="even" id="district_24">
<td class="name">Virginia Town City Public Schools</td>
<td class="">Delete</td>
</tr>
I am trying to use Selenium and xpath with it.
I am having problems when trying to select the 'delete' link that belongs to 'Virginia Beach City Public Schools'.
I am new to xpath.
I am trying:
xpath=(//td[text()='Beach')]/#class.contains('delete'))
but it is not finding the element.
Note: I cannot use the ID as these are repeated tests and the ID changes each time.
Try this:
//td[contains(text(),'Beach')]/../td/a[contains(#class,'delete_link')]
tr[#id="district_22"]//a[contains(#class,'delete_link')] would be a lot better.
It's not good to look at the text. After all it may get localized and edited in other ways. ID's however are ment to be unchanging and not duplicated.
I think you want to execute a automate scripts in loop, if this is the case then you can try the below code:
for(i=1,dist=22; i<-count; i++,dist++)
{
....
....
driver..findElement(By.xpath("//*[#id=District_"+dist+"]/..."))
}

keeping smarty index on page reload

I got a question.
i have tha following foreach loop:
{foreach from=$films item=film key=id}
<tr>
<td>
{$film.filmtitel}
</td>
<td>
{$film.zaaltitel}
</td>
<td>
plaats {$film.stoeltjes}
</td>
<td>
{$film.dag}
</td>
<td>
{$film.tijdstip}
</td>
<td>
5€
</td>
<td>
<a href="?page=winkelwagentje&action=verwijder&id={$smarty.forach.id.index}">
<img src="images/verwijderButton.png" alt="verwijderButton" title="verwijderButton"/></a>
</td>
</tr>
{/foreach}
these represent various items. now when its displayedin the browser the link gives me the url, ending with:
id=0 then the next is id=1 and so on.
When i remove 1 of these items through a button, the id's automaticly get rearranged so the index starts back with 0, then 1 and so on. What i would like to have is that if for instance i remove item with id=1 and the page gets refreshed, the id should remain deleted.
So the urls would look like:
id=0
id=2
id=3
anyone know if this is possible?
I understand your problem. You could rely on the keys of the array, but in this case you should populate the array in the same order and with the same id. It seems for me that this is a result set from a database table. It would be much easier to rely on an id of the database table which has unique values.
btw. you have a typo in your example code (...id={$smarty.forach...)

Resources