New Line '\n' is not working in Typescript with <br/> aslo? - html

New Line '\n' '' is not working in Typescript
my example typescript code is
this.custPartyAddress = estimation.partyName + ',' + '\n' +
estimation.partyAddress + ',' + estimation.partyLandMark + ',' + estimation.partyCity + '\n' +
estimation.stateName + ', Pin :' + estimation.partyPostalCode + ',' + '\n' + 'India.';
Showing out put is
Raju, Sr Nagar,Near Teample,HYDERABAD Andhra Pradesh, Pin :500032, India.
if above using in place of its showing like Bellow
Raju<br/>, Sr Nagar<br/>,Near Teample<br/>,HYDERABAD Andhra Pradesh<br/>, Pin :500032, India.
html databinding
{{custPartyAddress}}
i tried many ways didt get solution could u please suggest me solution ...

you need to use innerHTML to be interpreted as code
<div [innerHTML]="custPartyAddress"></div>
edit:
instead using {{custPartyAddress}} you can wrap in another div container using example from above (be carefoul, maybe will be necesarry to apply some styles for new container, example width: 100%)

Try to use Template literals with breaks in your text.

Related

how to add horizontal lines through barplot using ggplot2?

I would like the lines to look exactly like this
I've been able to replicate everything else thus far. just not the actual lines through the bars.
library(ggplot2)
plot <-ggplot(data=df, aes(x=chromosomes, y=size)) +
geom_bar(stat="identity", width=0.1) +
scale_x_discrete(position = "top") + theme(axis.ticks.x = element_blank())+
expand_limits(y=c(0,180)) + scale_y_reverse() '''

multi-line in aurelia component html attribute property

This is a weird question about possibly embedding a string in an aurelia html file within the attribute tag but I would like to keep my tab and line formatting.
So, in my TS file I have the following:
this.queryDateStart += "type=EntityOne&dateQueryString=";
this.queryDateStart += "" +
"eOr( " +
"eAnd( " +
"eAnd( facetName:isExcluded AND facetValue:No );" +
"dAnd( facetName:deadlineDate AND "+ dateRangePredicate + ");" +
"); " +
"dOr( " +
"(facetName:excludedUntilDate AND "+ dateRangePredicate + ")" +
");" +
");"
And instead of having the following:
<section as-element="ab-deadlines" data-query="${queryDateStart}"></section>
I would like to actually pass the literal string from above.
But with the line spaces.
Would that break anything?
So for example ( going to try this today) - in my html file I would put:
<section as-element="ab-deadlines"
data-query="
eOr(
eAnd(
eAnd( facetName:isExcluded AND facetValue:No );
dAnd( facetName:deadlineDate AND ${dateRangePredicate} );
);
dOr(
(facetName:excludedUntilDate AND + ${dateRangePredicate} )
);
);"></section>
About breaking: it shouldn't break anything. In the end, it's just normal HTML attribute, and as long as the spec allows it, it works in Aurelia, as Aurelia works directly, and plainly with HTML elements.
You can see it yourself at this sandbox https://codesandbox.io/s/z20qx0q263

How to do " or \r in Prism.js in Angular6

So I'm trying to have Prism highlight the following Arduino code snippet on my site.
client.print(String(\'\'GET \'\') + url + \'\' HTTP/1.1\r\n\'\' +
\'\'Host: \'\' + host + \'\'\r\n\'\' +
\'\'Connection: close\r\n\r\n\'\');
I initially had to change all of the " to '' but now it interprets \r\n as a line break and displays it as such. Any thoughts?
Ok, actually just got it. Use \'\'\\r\'\' to express what will be interpreted as "\r".

An html tag other than a textarea where \n is correctly interpreted

I have the following html code:
<textarea data-bind="text: signaletic()"></textarea>
where signaletic is from here:
client.signaletic = ko.computed(function () {
var name = ...
var address = ...
var postcode = ...
var city = ...
var country = ...
return name + '\n' + address + '\n' + postcode + ' ' + city + '\n' + country;
});
It works, I mean I have a new line between elements thanks to '\n'.
Now I would like to use another control than a textarea, I need a read-only control. I try with a simple div but my '\n' don't work anymore. Does someone have an idea for replacing my textarea with a read-only html element where '\n' is correctly interpreted?
You can apply the white-space: pre CSS property to force an element to respect newlines.
Can't you just use <textarea readonly>blar \n blar \n blar</textarea>?
I think you can use the same textarea approach but add the disabled attribute to the textarea. There is a readonly attribute too, then you cannot edit the document but can interact with the textarea control (resize and all). Your choice.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
An example (http://www.w3schools.com/tags/att_textarea_disabled.asp) ..

Correct way to set html div position when inserting html via ajax

I am dynamically building html in javascript. This will then be inserted into an element. What is the correct way to set the top, left, width and height properties within the html that I am creating. My current technique works in IE, but not Chrome or Safari. This is how I'm currently doing it (controlgroup is an object containing my properties):
html += '<div id="' + controlgroup.id + '" class="controlgroup ui-widget-content"';
html += ' style="{';
html += 'top:' + controlgroup.top + '; left:' + controlgroup.left + ';';
html += 'width:' + controlgroup.width + '; height:' + controlgroup.height + ';';
html += '}">';
html += 'cg:' + controlgroup.id + ' ' + controlgroup.left + ',' + controlgroup.top;
html += '</div>';
I then do this:
$('#formcontainer').html(html);
I need the ability to specify exact coordinates, so I can't use 'predefined' css classes here. Thanks very much.
1) You'll want to make that you are using left, right, height, and width values that have px attached. So instead of setting width:50; set it to width:50px;.
2) You'll want to add position:relative; to your style.
3) The {} brackets are not needed
Working Demo: http://jsfiddle.net/Jaybles/6fbvT/2/