How to binding `ngx-intl-tel-input` with only "internationalNumber" - angular7

I'm use ngx-intl-tel-input, when binding have model with:
"phone":
{
"countryCode": "",
"dialCode": "",
"internationalNumber": "",
"nationalNumber": "",
"number": ""
}
but I want model:
"phone":
{
"internationalNumber": ""
}
what can I do?
Thank you very much!

you can have middleware variable for the binding :
<ngx-intl-tel-input [(ngModel)]="mobile"> <ngx-intl-tel-input>
for example:-
let mobile;
let internationalNumber="";
internationalNumber=mobile.internationalNumber;
now your binding is ready!

[(ngModel)] actually comes with event binding and property binding. Below two lines are equal.
<input [ngModel]="yourVariable" (ngModelChange)="yourVariable = $event">
and
<input [(ngModel)]="yourVariable">
So for your question, you can do something like below.
<input [ngModel]="yourVariable" (ngModelChange)="yourVariable = $event.internationalNumber">

Related

Renaming type for FSharp.Data JsonProvider

I have a JSON that looks something like this:
{
...
"names": [
{
"value": "Name",
"language": "en"
}
],
"descriptions": [
{
"value": "Sample description",
"language" "en"
}
],
...
}
When using JsonProvider from the FSharp.Data library, it maps both fields as the same type MyJsonProvider.Name. This is a little confusing when working with the code. Is there any way how to rename the type to MyJsonProvider.NameOrDescription? I have read that this is possible for the CsvProvider, but typing
JsonProvider<"./Resources/sample.json", Schema="Name->NameOrDescription">
results in an error.
Also, is it possible to define that the Description field is actually an Option<MyJsonProvider.NameOrDescription>? Or do I just have to define the JSON twice, once with all possible values and the second time just with mandatory values?
[
{
...
"names": [
{
"value": "Name",
"language": "en"
}
],
"descriptions": [
{
"value": "Sample description",
"language" "en"
}
],
...
},
{
...
"names": [
{
"value": "Name",
"language": "en"
}
],
...
}
]
To answer your first question, I do not think there is a way of specifying such renaming. It would be quite reasonable option, but the JSON provider could also be more clever when generating names here (it knows that the type can represent Name or Description, so it could generate a name with Or based on those).
As a hack, you could add an unusued field with the right name:
type A = JsonProvider<"""{
"do not use": { "value_with_langauge": {"value":"A", "language":"A"} },
"names": [ {"value":"A", "language":"A"} ],
"descriptions": [ {"value":"A", "language":"A"} ]
}""">
To answer your second question - your names and descriptions fields are already arrays, i.e. ValueWithLanguge[]. For this, you do not need an optional value. If they are not present, the provider will simply give you an empty array.

Cannot read property 'empId' of undefined

following is the response(Json) :
{
"formId": 2,
"empId": {
"empEmail": "abc#gmail.com",
"empName": "John",
"empId": "1234",
"role": 3
},
"skillClass": "UI",
"fromDate": "2019-07-18T18:30:00.000+0000",
"toDate": "2019-07-26T18:30:00.000+0000",
"status": "open",
"userComments": "ee3de3",
"allocatedHours": 0,
"comments": null
}
The TS. file is :
data = {};
this.data = reponse;
And the HTML:
input type="text" [(ngModel)]="data.empId.empId" disabled name="empId" minlength="4" #empId="ngModel" class="form-control" required
But I get an error:
Cannot read property 'empId' of undefined
How do I get rid of this error?
Though this question seems a little incomplete, it looks like you have a typo in:
this.data = reponse;
Likely it should be:
this.data = response;

How to get the optgroups object of the selected fields in the getRule json object output?

I have requirement to get the optgroup of selected field in the query builder, but as of I am aware queryBuilder('getRules') doesn't provide. For example:- I want to get optgroups object of selected field 'price' in the json output. How to get it? Please give some idea.
-optgroups object
optgroups: {
core: {
en: 'Item'
}
}
-json output object
{
"condition": "AND",
"rules": [
{
"id": "price",
"field": "price",
"type": "double",
"input": "text",
"operator": "less",
"value": "10.25"
}
]
}
As I was answered for this question on GitHub by the library developer(#mistic100). The answer is-
You can use the data property of the filter https://querybuilder.js.org/index.html#filters
It will be copied as it on each rule using the said filter.

need help: editor and numbers asp.net

I have an editor field in asp.net which needs to be integer input only between 1 and the size of a list. Atm i got this as code
#Html.Editor("Prioriteit" + item, new { htmlAttributes = new { #type = "number", min = "0",step = "1", value = "0" } })
this isn't to the maximum of the list, I know this. However when i open the page i can still add text.
View with text in editor
Someone can help me out?
thanks in advance
Changed the code for the sake of someone linking it to another question
code
#Html.TextBox("Prioriteit" + item,null, new { htmlAttributes = new { #type = "number", min = "0",step = "1", value = "0" } })
still the same
`
You can also do the following:
<input type="number" min="0" step="1" value="0" name="Prioriteit#item" />
Try this:
#Html.TextBox("Prioriteit" + item, "0", new { #type="number", min = "0", step = "1" })

How do I model a key/value for which the key is not known in Swagger

I have a simple JSON object that can contain key/values for which the exact values are not known upfront. They depend on some server side process. How do I model this in Swagger?
An example of the JSON would be:
...
,message: "invalid length. Must be in between {min} and {max}"
,attributes: {
min: 0
,max: 6
}
...
Another example would be:
...
,message: "You must fill out this field as well because {field} has a value"
,attributes: {
field: "age"
}
...
The following solution will only work with Swagger 2.0.
Define the model as described like this:
{
"type": "object",
"properties": {
"message": {
"type": "string"
},
"attributes": {
"type": "object",
"additionalProperties": {}
}
}
}
This describes attributes as a map of properties, where the value can be anything (string, number, array and even an object).

Resources