I don't see the query strings in the route after defining them in routerlink in Angular - angular-routing

I'm defining this route
<a class='nav-link' [routerLink]="['/ofertas']" [queryParams]="{Todas:'No'}">Ofertas</a>
But I see this
That is, I see http://localhost/ofertas when I hope http://localhost/ofertas?Todas=No
Any idea, please?
Thanks

Related

New to jquery. Starts with selector breaks the code. what's is wrong?

Thanks for the help. I'm trying to use a jQuery selector to watch for a click on a group of elements, that start with particular characters. I have come up with the following code, but I must be missing something. If I hard code the ID (ie. $("#test_1")...), the code works:
<body>
<div id="content">
<div id="parentcontainer">
<div id="test_1"></div>
</div>
</div>
</body>
<script>
$(window).load(function(){
$("#statusbar").text("Ready");
$("#parentcontainer").click(function(){alert("parent clicked");});
$("#btnaddelement").click(function(){alert("Add Button Clicked");});
$("[name^='test_']").click(function(e){e.stopPropagation();
alert("Child Clicked");});
});
</script>
You are selecting on $("[name^='test_']") which will give you elements who have a name attribute that start with test_. You need to select on $("[id^='test_']") for elements with an id that start with test_. That is one example of what you are getting with your hard-coded success of $('#test_1') -- an element whose id attribute is test_1.
Also, be aware if you are not already that xpath is the language used for selectors, so you can do all kinds of incredible selection if you become familiar with it.
Yes, you missed something. Change the div's attribute id to name will work
<div name="test_1"></div>
Actually, class was used more frequently.
And there are an opinion I want to improve the code.
Try to use the jquery's $(document).ready instead of DOM's load. Because load will wait for all the sources to be loaded compeletely before the js code can be executed, for example, all the photos are downloading ok.
I hope this help!

Simple DOM cloneNode issue

im having another rather simple issue with using cloneNode. I'm trying to duplicate a li node back into its own ul using java and I can't seem to find why its not working.
I have tried multiple things but I cant for the life of me figure it out.
I want this:
<ul id="mylist">
<li><h3>My Image:<img src="myImage.png"></h3></li>
</ul>
To look like this:
<ul id="mylist">
<li><h3>My Image:<img src="myImage.png"></h3></li>
<li><h3>My Image:<img src="myImage.png"></h3></li>
</ul>
I am using this function:
function myFunction(){
parent=document.getElementById("myList");
child=parent.getElementbyTagName("li")[0];
clone= child.cloneNode(true);
parent.insertBefore(clone,child);
}
</script>
Unsure as to why its not working, I pulled the code almost identically from an online source. If someone could help with my newbie question I would very much appreciate it.
I often find when copying javascript from the inter-rent, the author has never checked his code for typing errors or maybe they're deliberate to encourage a bit of understanding.
This works:
<ul id="myawesomelist">
<li id="x"><h3>My awesome image:<img src="myawesomeimage.png"></h3></li>
</ul>
and here's the javascript:
function myawesomefunction()
{
var myawesomeparent=document.getElementById('myawesomelist');
var myawesomechild=myawesomeparent.getElementsByTagName('li')[0];
var myawesomeclone=myawesomechild.cloneNode(true);
myawesomeparent.insertBefore(myawesomeclone,myawesomechild);
}
And here's the fiddle I built it in:
http://jsfiddle.net/g51n8sor/

Declarative support questions

I am trying to add an htmlview (which is using declarative support according to SAP's docs) to an index page that is also using declarative support. Using data-sap-ui-type="ui.MyView" makes me to ask two questions:
Is there any equivalent to sap.ui.localResources in declarative support?
data-ui-type is not adding the view.html suffix to the view that should be laoded. Is there a special pattern for MVC in declarative support or is there currently no way to implement it?
Kind regards,
Nico
find some basic samples here:
https://openui5.hana.ondemand.com/#docs/guide/MVC.html
First of all I believe that you always have to set sap.ui.localResources in code.
As you can see instanciating a HTMLView from an HTMLView goes like this:
<div data-sap-ui-type="sap.ui.core.mvc.HTMLView" id="MyHTMLView" data-view-name="example.mvc.test2"></div>
This will load example.mvc.test2.view.html and place it into your parent view.
Generally speaking the JS API translates into HTMLViews like this:
new sap.ui.AnyControl("myId", {
aLittleProperty: "10",
property: false,
press: functionInMyController,
morePress: a.static.myFunction,
defaultAggregation: [
new sap.ui.OtherControl("otherId1"),
new sap.ui.OtherControl("otherId2")
],
anotherAggregation: new sap.ui.OtherControl("otherId3")
}).addStyleClass("myClass");
<div data-sap-ui-type="sap.ui.AnyControl"
id="myId"
class="myClass"
data-a-little-property="10",
data-property="false"
data-press="functionInMyController"
data-more-press="a.static.myFunction">
<div data-sap-ui-type="sap.ui.OtherControl" id="otherId1"></div>
<div data-sap-ui-type="sap.ui.OtherControl" id="otherId2"></div>
<div data-sap-ui-aggregation="anotherAggregation">
<div data-sap-ui-type="sap.ui.OtherControl" id="otherId3"></div>
</div>
</div>
Note that:
The id and CSS classes are set with the regular HTML attributes
Property names translate from camelCase to lower-case separated with "-" (due to the fact that HTML is not case-sensitive)
No matter what type the property is you of course have to put it in quotes in HTML
Whatever you put directly inside a HTML-defined control is considered to belong into it's default aggregation
BR
Chris

Zend Frameword 2: How to set a html link (img) in a legend of the fieldset?

I used zf2 to design a website.
And the form is something like this:
$this->add(array
'options'=>array(
'label'=> 'title1'))
And finally it shows like this:
<form>
<fieldset>
<legend>title1</legend>
<label>****</label>
</fielset>
</form>
Now, I wanna add a link or an image after the title1, for example:
<form>
<fieldset>
<legend>title1<a href=''>link</a></legend>
<label>****</label>
</fielset>
</form>
How can I do this?
You can't. Well, at least not without overwriting the specific ViewHelper (probably formCollection()). In ZF2 all Labels are run through the Zend\View\Helper\EscapeHtml ViewHelper. Therefore using any sort of HTML inside Labels is not supported in any way.
While going by specification it may be allowed to use inline-elements inside the <legend> Element, semantically it looks a little different. The <legend> shall do nothing but to describe the contents of the <fieldset>.
Anyways, opinions aside, as i've mentioned, you'll have to overwrite the ViewHelper and then skip the use of the EscapeHtml ViewHelper, as it's done in this line of the formCollection() Code

Zend_Forms Errors Decorator - remove html tags

Error decorator input errors such way:
<ul class="error">
<li>Error message</li>
</ul>
How can i remove this tags and leave only error message text?
I think a neat solution to the problem is to create your own custom decorator, and use it instead of the "Errors" decorator.
$errors = $zendForm->getErrorMessages();
I think this should work? Not 100% sure though I don't have time to check documentation.