How to compare a template var in the html page in ionic 4 - ionic-framework

I am a ionic beginner, and I really do not know how to compare a var in *ngIf.
I have a user class, and one of its atribute is averageRating, that is a Number. In my rating.page.html I can show it like this:
{{user.averageRating}} but I want to show it in a more natural way, with stars.
I know I can not compare like this: *ngIf="{{user.averageRating}}>=1"
So I have try to declare a public ratingActual: Number in my class RatingPage in my rating.page.ts and asign value in the constructor:
this.ratingActual = this.user.averageRate;
And I do in my html: *ngIf="ratingActual>=1"
But is not working. However if I change this.user.averageRate by a number it works.
I would like to understand wy is not working and find an solution, an easy one if it is posible.
Thanks in advance!

Related

Getting value of multiple <select> that has chosen jquery plugin

I have a <select mutiple> which has the chosen function attached to it, turning it into something like a tag selector.
I am then sending its multiple values via an ajax call.
I am currently using this:
var x_CoPayers = $("#x_CoPayersChargeEdit").val();
but when I view the parameters that are sent by ajax, they look like this:
x_CoPayers[] = 9813
x_CoPayers[] = 9786
Of course that doesn't work for me, because the parameter i am looking for on the other side is called x_CoPayers.
I would like them each to be called x_CoPayers, or alternatively, like this: x_CoPayers= 9813,9786.
I have also tried this, without result:
var x_CoPayers = $("#x_CoPayersChargeEdit").chosen().val();
Thank you.
Ok, found the answer ;)
add join(',') at the end, so:
$("#x_CoPayersChargeEdit").val().join(',');

Kentico: Can i get Page Title via nodeID?

I would like to display a list of a couple of my pages in a list.
Is there a macro or something else to get the page title of another site then the actual one?
All i need is a little smart function that can give me the name of a page.
Thanks for your help.
If you have the nodeID of the page you want the title of, you can use the TreeHelper static functions.
TreeNode yourNode = TreeHelper.SelectSingleNode(nodeID);
then easily enough access the name from there.
yourNode.DocumentName;
Note the difference between a TreeNode and a Document is that there are possibly multiple Document's for one TreeNode, where each is a different language/culture.

check if custom attribute has specific value

My problem seemed easy at first but i got stuck.
I have some containers (divs) in my page with some custom attributes.
<div class="myclass" myattr1="blah" myattr2="text1-text2-text3-text4-"></div>
myattr1 and myattr2 are defined by me.
All divs are visible on page load.
Now, depending on user selection from a list, i want to show only the divs with myattrib1="blah" and hide the rest.
I tried the following code, with no success at all
$('#mySelectID').change(function()
{
var startName = $(this).val();
$(".myclass").not('[myattrib1!="+startName+"]').toggle();
});
The same approach will be used to filter results by attrib2, but there i will use myattrib2|="+startName+" ( i think this is correct - thats why i have the extra - on the end of myattr2="text1-text2-text3-text4-").
Can anyone advice me on how to properly achieve this kind of filtering?
thank you!
You are close, but as you can see form the syntax highlighting, your are not performing string concatenation. +startName+ will be taken literally. Fix the quotes and your fine:
.not('[myattrib1!="' + startName + '"]')
Note that you should be using data-* attributes instead of custom ones.

How do I get Zend_Navigation to work with database defined data?

I've got a Zend_Navigation component I use to display breadcrumbs on a page. It currently says something like:
"Companies > Edit a Company"
when displaying the edit form. I would like to make it say something like
"Companies > Editing FooBar"
What's the best way to accomplish that?
I had the problem that I wanted to show breadcrumbs even when the parent is set to not visible. Drove me nuts until I found the reason. Your problem is not much different, I think.
I have a unique ID set with basically all links; hence, I can fetch all nodes like the following:
// in view scripts
$navObject = $this->navigation()->findOneById($id);
// now you can manipulate the object however you like
$navObject->setLabel('Editing FooBar');
You can find the node by other means, there is findOneBy() method where you have to pass the target object.
Once I printed the breadcrumbs I had to reset setVisible(false) to the old value, though. Depending on your needs you might have to reset the label, too.

Need to print out all links on a sidebar in selenium (xpath?)

I need to find any extra links and print them out. I started by doing:
get_xpath_count('//li/a')
and comparing it to the size of an array that holds the name of all the links for the sidebar. When the count is too high/low, I need to print out all the extra/missing links. I would like to make a list of the names so I can compare it to the array. I've tried a few things like get_text('//li/a'), which returns the name of the first. get_text('//li/a[1]) does the same, but any other index returns nothing.
Any ideas? Also, I need the name that's displayed on the link, not the actual href.
Edit* Also, i'm pretty new to selenium and Xpath. Please let me know if there's info I let out that is needed, or just any suggestions towards thew way I'm going about this.
I have been able to get this to work using CSS element locators. Since I use CSS selectors far more often than Xpath, I find it easier to always use them with Selenium as well.
$selenium->get_text("css=li a:nth-child(1)")
$selenium->get_text("css=li a:nth-child(2)")
$selenium->get_text("css=li a:nth-child(...)")
$selenium->get_text("css=li a:nth-child(n)")
Use:
(//li/a)[$someNumber]
this will get you the text of $someNumber-th //li/a in the XML document.
In order to know what values to use to substitute the $someNumber with, you need to know the total count of these elements:
count(//li/a)
This is in JAVA. You can use the same concept in perl
int totCountInPage=selenium.getXpathCount(//li/a);
for(int count=1;count<=totCountInPage;count++)
System.out.println(selenium.getText("xpath=//li[count]/a"));
This should print text inside the anchor links under all li tag.