Angular 8 Display variable inside a variable in a template - angular6

I have tried to escape the "{{ }}" in the string stored on my DB, used the ASCII character instead of the curly braces, put it inside [innerHTML] but the result was always the same.
Do you know how can I solve this?
Thank you very much!

You want to show data from an object using there key and value,
first see in which form your data is coming, for example:-
suppose u have an object:
this.data = {'title': 'XYZ'} in your .ts file then you can show output like this:
<p>{{data.title}}</p> and output will be XYZ

Related

How to replace member in JSON in MariaDB

I have JSON field in a table which contains the following:
[{"Example":"2"}]
I've seen JSON_REPLACE which will allow me to replace the value of any JSON member, but its the key itself I need to replace, is there a function that will allow me to change the above to:
[{"ex":"2"}]
Edit, sorry I missed out something important, the JSON is actually in an array. I need to replace a member in an array element.
Thank you to #nOOb for link, have fixed with:
UPDATE threats SET jsonParams=
JSON_INSERT(JSON_REMOVE(jsonParams, '$[2].Example'),
'$[2].ex', JSON_EXTRACT(jsonParams, '$[2].Example'));

How to export a mysql SELECT to JSON, not as escaped text?

After trying different things for hours now it's starting to drive me nuts. So I really hope somebody here could help me with this.
I have a test select query which has only one field that is the result of JSON_OBJECT() function, so that should be JSON (no text). But whatever I try, phpMyAdmin keeps escaping the json keys on an export of the result grid. Which is obviously not what I want when exporting to JSON.
Just a simple example, this:
SELECT JSON_OBJECT("key", "value") as json, results into this:
screenshot
and exports to something like this:
{
"json": "{\"key\": \"value\"}"
}
Which is obviously no valid json as key should be a key, not part of a string.
Is there somebody out there that could please tell me how to export json data as real json without acting like the output of JSON_OBJECT() is text, so without the wrong escapes?
Thanks in advance!!
Using:
- MariaDb 10.4.10
- phpMyAdmin 4.9.2

How to enter Jinja variables as HTML values

I am using Jinja and am trying to set the "value" of the option to a variable. I tried this: <option value = {{stock['name']}}>{{stock['name]}}</option>, but it thinks that the {{stock['name'is a string, and the bits after that are normal. Does anyone know how I can fix this?
The stock['name'] may be int or string but still the value will be put as a string like you said it thinks so. So, after you select your option and pass back to server via form or ajax or whatever then in the server side you can typecast the value back to integer and use it like:
#app.route('/stocks',methods=['GET','POST'])
def func():
if request.form.get('stock'):
stock_value = int(request.form.get('stock'))
# like so you can use the integer value if you want
but if I did not get you , can you make it clear again?
I simply needed to add spaces, so that the code is {{ stock['name'] }}

How to remove brackets, quotes from table?

I have a column uuid looking like as shown in the picture. It is a JSON type. I want to remove
the square brackets from each row and then the quotes (which I can remove using JSON_UNQUOTE). I tried using JSON_EXTRACT(uuid, '$[0]') but with this, I can only select one value at a time e.g. "5f5616fd88b3484bb636e6dbf5a702b6" not all the values inside the square brackets at once.
Once this is done, I want to remove quotes from each value and then again add brackets back. After this I want to export it as csv and use it for building a network graph using Networkx python library.
I am very open to suggestions, if my idea is wrong. Thank you!
You can't do that with JSON functions, because what you are trying to produce is not valid JSON.
However, you can process the json value with string functions. If you just want to replace the embedded double quotes, you can do:
replace(uuid, '"', '')

MYSQl export result set csv and send it as out param or variable through a proc

i found link web which tell how to export result set to OUTFILE.
http://sandaldjepit.com/2009/how-to-export-mysql-data-table-to-excel-csv-format-with-sql-query/
But I want store the resultset in a longtext variable return it as out parameter or sent as 1 row, 1 column record ,like:
select str;
I have tried to do work around by using concat and group_concat, but if any value is null the whole str will become null.
Can anyone suggest a work around.
I am ok, if i have to write the result to the OUTFILE and then load to variable.
As i wont have control to local file system, its better the file is saved to a place where mysql has access.
Or any other idea with code is welcomed.
Please guide me through
Try using ifnull(col_name, "") function. If a specific column is null, it uses an empty string instead.