Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Consider the data format as
{
users: [....]
userPropNames: [...]
showingAllUsers : false
usersPresent : true
}
I am building the HTML table as per following rule
- Row will be defined based on userProperNames
- The columns will vary based on number of users in the dataset
The way I started is
<tbody>
<tr ng-repeat="key in queryResults.userPropNames">
<td>checkbox</td>
<td>{{key}}</td>
<td>{{queryResults.users[1].properties[key]}}</td>
<td>{{queryResults.users[2].properties[key]}}</td>
<td>{{queryResults.users[3].properties[key]}}</td>
</tr>
</tbody>
and it displays the table correctly with three additional column for users.
Now I though to iterate over the users in <td> and create as many columns as users.
so I did
<tr ng-repeat="key in queryResults.userPropNames">
<td>checkbox</td>
<td>{{key}}</td>
<td ng-repeat="user in queryResult.users">
{{user.properties[key]}}
</td>
</tr>
Now I do not see any user column data
What's incorrect with this approach?
You have a typo.
<td ng-repeat="user in queryResult.users">
Should be:
<td ng-repeat="user in queryResults.users">
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have to do something like this but i am kind of stuck in here.
So i have a table with header column as
Fe Ni Co Magnetic NonMagnetic
below each item, i have input box of value in which user can enter value.
In the above table Fe, Ni are magnetic and Co is Non-magnetic.
So, when user enters value under Fe and Ni, its sum get automatically inserted Under Magnetic and if he enter value for Co, its value will get inserted under NonMagnetic.
I have tried using id of box below item name and id of item but was unable to get this done. I want to do all this using html and javascript.
This is just a part of code. Whole code is way bigger. So i don't want to confuse, so i am just putting context of part code.
If anyone can suggest me some ways to do it. That will be helpful.
You can easily do this like so:
const feInput = document.getElementById('fe');
const niInput = document.getElementById('ni');
const coInput = document.getElementById('co');
const magnetic = document.getElementById('magnetic');
const nonMagnetic = document.getElementById('non-magnetic');
function updateMagnetic() {
const fe = feInput.value;
const ni = niInput.value;
magnetic.innerHTML = Number(fe) + Number(ni);
}
function updateNonMagnetic() {
const co = coInput.value;
nonMagnetic.innerHTML = Number(co);
}
feInput.addEventListener('input', updateMagnetic);
niInput.addEventListener('input', updateMagnetic);
coInput.addEventListener('input', updateNonMagnetic);
<table>
<thead>
<tr>
<th>Fe</th>
<th>Ni</th>
<th>Co</th>
<th>Magnetic</th>
<th>NonMagnetic</th>
</tr>
</thead>
<tbody>
<tr>
<td><input id="fe" type="number" /></td>
<td><input id="ni" type="number" /></td>
<td><input id="co" type="number" /></td>
<td id="magnetic">0</td>
<td id="non-magnetic">0</td>
</tr>
</tbody>
</table>
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
<form *ngIf="filters">
<ng-container *ngTemplateOutlet="filterTemplate; context: {$implicit: filters}"></ng-container>
</form>
<ng-template #filterTemplate let-filters>
<ng-container *ngFor="let field of filters">
{field.something}
</ng-container>
<ng-template>
filters in ng-container is null, can anyone tell me where/what am I doing wrong?
If you are setting up filters data proper then there is no issue in your code :
<ng-container *ngTemplateOutlet="filterTemplate; context: {$implicit: filters}"></ng-container>
<ng-template #filterTemplate let-filters>
<ng-container *ngFor='let field of filters'>
{{field.key}}<br/>
</ng-container>
<ng-template>
WORKING DEMO ( With ngIf / and simulated data delay with setTimeout)
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I have a JSON object which needs to be searched if I input a angular form with two dates
I tried searching using a single date angular form control.
template code:
<div>
<div class="card w-75">
<div class="card-body">
<h5 class="card-title">Invoice summary</h5>
<hr>
<p class="card-text">Total revenue made by this venue: <strong>
{{totalRevenue}}</strong></p>
<p *ngIf="invoicesFiltered === true" class="card-text">Revenue
made on <strong>{{inputInvoiceDate}}</strong> is <strong>
{{filteredTotalRevenue}}</strong></p>
</div>
</div>
<div>
<div style="float:left;">
<label for="queryInvoiceDate">Start Date:</label>
<input
#queryInvoiceDate
(change)="filterInvoice(queryInvoiceDate.valueAsDate)"
type="date"
class="form-control"
style="width:100%">
</div>
<table class="table table-striped" [mfData]="filteredInvoices" #mf="mfDataTable" [mfRowsOnPage]="10">
<thead>
<tr>
<th>Advertiser Acct Balance</th>
<th>Service Fee Amt</th>
<th>Target Amt for Venue</th>
<th>Venue Acct Balance</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let invoice of mf.data">
<td>{{invoice.acntbalances}}</td>
<td>{{invoice.servicefeeamount}}</td>
<td>{{invoice.targetamount}}</td>
<td>{{invoice.targetbalance}}</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="4">
<mfBootstrapPaginator [rowsOnPageSet]="[10,15,20]"></mfBootstrapPaginator>
</td>
</tr>
</tfoot>
</table>
</div>
component code:
filterInvoice(queryInvoiceDate: any) {
this.inputInvoiceDate = queryInvoiceDate.toISOString().split('T')[0];
this.filteredInvoices = (queryInvoiceDate) ?
this.invoices.filter(i =>
i.timestamp.includes(queryInvoiceDate.toISOString().split('T')[0])) : this.invoices;
console.log(queryInvoiceDate.toISOString());
this.filteredTotalRevenue = this.filteredInvoices.reduce((sum, invoice) => {
return sum + invoice.targetamount; }, 0);
}
What would i need to do if I want to pass two dates and search for all JSON values falling between the passed dates and specific timestamps?
I would strongly recommend using momentjs if you need to do anything with dates in javascript that isn't trivial. That is likely to be the case if you are writing a real-world application as opposed to a theoretical exercise. Javascript dates are messy and nasty, and you can see that you are already doing ugly things like .toISOString().split('T')[0] in order to extract the date. In momentjs, you can do something like moment(queryInvoiceDate1).isBefore(moment(i.timestamp)) && moment(queryInvoiceDate2).isAfter(moment(i.timestamp)) to filter the invoices by the date range. This will let you write much more readable and maintainable code.
On the other hand, the nice thing about ISO strings is that they can be compared vie lexicographical (alphabetical) sort, so '2018-09-01' is > '2018-08-01' and < '2018-09-03' for instance. So you could use your current method of extracting the date from the ISO string and simply use >= and <= operators in the filter.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
<div id="rep">
<table cellpadding="1" cellspacing="1">
<tbody>
<tr>
<td><img src="assets/x.gif" class="r1"></td>
<td id="l4" title="r1">5/1000</td>
<td><img src="assets/x.gif" class="r2"></td>
<td id="l3" title="r2">15/1000</td>
<td><img src="assets/x.gif" class="r3"></td>
<td id="l2" title="r3">152/1000</td>
<td><img src="assets/x.gif" class="r4"></td>
<td id="l1" title="r4">100/1000</td>
</tr>
<tr><td colspan="6"></td><td><img src="assets/x.gif" class="r5""></td><td>1000/1000</td></tr>
</tbody>
</table>
</div>
Hi...
I was trying get value/text from td with id 11-14.
but using $('#14') or getElementById is always failed.
Already try using get all table but location index sometime change.
i hope someone can help me. thank
You've the L+NUMBER as mentioned in the comment :
l1!=11
_____^ //Character 'l'
______^ //Number '1'
So you've just to use the real id's in your code :
$("#l1").text();
This is a L before the 4 and not a "one"
So you have to do this :
$("#l4")
And not
$("#14")
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
Ok here is my questation. im stuck for a while
I have a table 3x3. In that table I have 5 images;
1st image is in the middle cell of the top row, saying "Home"
2nd, 3rd, & 4th images are in the middle row
2nd image is in the left column and says "Software"
3rd image is in the middle of the table and displays my logo
4th image is in the right column and says "Forum"
5th image is in the 3rd row, middle cell and says "About"
So I want to keep the logo image (in the center of table) displayed until user hovers over one of the 4 categories (Home, Forum, Software, About). When they hover over the category, the middle image should become an image representing that specific category.
For example, if user hovers over Software image (left column, middle row), logo image would be replaced with image representing Software.
Sorry for bad language and I hope you get idea of what I want to do
This should get you in the right direction.
HTML
<table>
<tr>
<td id=""></td>
<td id="home">Home</td>
<td id=""></td>
</tr>
<tr>
<td id="software">Software</td>
<td id="logo">Logo</td>
<td id="forum">Forum</td>
</tr>
<tr>
<td id=""></td>
<td id="about">About</td>
<td id=""></td>
</tr>
</table>
jQuery
var logoBlock = $("#logo");
$("a").hover(
function(){
logoBlock.find("a").text( $(this).text()+" is Hovered" );
},
function(){
logoBlock.find("a").text("Logo");
}
);
http://jsfiddle.net/daCrosby/MvWYD/
Is this what you want to do?
jsFiddle here
HTML:
<table id="tbl">
<tr><td></td><td><img id="hom" src="http://png-2.findicons.com/files/icons/1261/sticker_system/128/home.png"></td><td></td></tr>
<tr>
<td>
<img id="swr" src="https://cdn1.iconfinder.com/data/icons/ecommerce-and-business-icon-set/256/software.png">
</td>
<td>
<img id="lgo" src="http://graph.facebook.com/1671019266/picture?type=large">
</td>
<td>
<img id="frm" src="http://wespenre.com/graphics/forum-icon.png">
</td>
</tr>
<tr id="tr2"><td></td><td><img id="abt" src="http://png-3.findicons.com/files/icons/730/soft/128/info.png"></td><td></td></tr>
</table>
javascript/jQuery:
/*
See these posts:
http://stackoverflow.com/questions/554273/changing-the-image-source-using-jquery
*/
var img_logo = $('#lgo');
$('img').hover(
function() {
var xx = $(this).attr('src');
img_logo.attr('src', xx);
},
function() {
img_logo.attr('src', "http://graph.facebook.com/1671019266/picture?type=large");
}
);