东西板小部件 - 毫秒到微小的转换
我正在接管以前的成员代码,该代码与示例html代码非常相似,并且提供了JS函数在这里有一些小更改。
当我打开小部件时,我可以更改有关网关的一些属性(例如高优先级布尔值或无活动超时)。该小部件在MS中需要时间,在进入时看起来令人困惑,因此以前的成员创建了一些设定的时间,与MS中的时代有关,请参见Visual Image。 下拉菜单的示例图像。 HTML代码是(我根据不需要编辑了其他字段的零件):
<form #editEntityForm="ngForm" [formGroup]="editEntityFormGroup"
(ngSubmit)="save()" class="edit-entity-form">
<div formGroupName="attributes" fxLayout="column" fxLayoutGap="8px">
<div fxLayout="row" fxLayoutGap="8px" fxLayout.xs="column" fxLayoutGap.xs="0">
<mat-form-field fxFlex class="mat-block">
<mat-label>Disconnection Timeout</mat-label>
<mat-select matInput formControlName="inactivityTimeout">
<mat-option value=1800000>30 min</mat-option>
<mat-option value=3600000>60 min</mat-option>
<mat-option value=7200000>120 min</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
</div>
</form>
相应的JavaScript函数(从我能够找出的内容)是:
function EditEntityDialogController(instance) {
let vm = instance;
vm.entityName = entityName;
vm.entityType = entityId.entityType;
vm.entitySearchDirection = {
to: "TO"
};
vm.attributes = {};
vm.oldRelationsData = [];
vm.relationsToDelete = [];
vm.entity = {};
vm.editEntityFormGroup = vm.fb.group({
entityName: ['', [vm.validators.required]],
entityType: [null],
entityLabel: [null],
type: ['', [vm.validators.required]],
attributes: vm.fb.group({
inactivityTimeout: [null, [vm.validators.pattern(/^-?[0-9]+$/)]],
}),
oldRelations: vm.fb.array([]),
relations: vm.fb.array([])
});
/*This function goes on but it is just a bunch of inner functions like
.save or .cancel*/
尽管此设置不是很好,但是很好,因为它实际上允许输出发送到MS中的服务器属性,但是,即使HTML代码表示值= 180000,它也将其作为字符串而不是整数发送。值=“ 180000”。 显示字符串类型的图像。
我正在尝试将此当前设置作为整数输出, ,或将其更改为文本输入(我能够做到并且它有效,但仅在MS中)显示在几分钟内显示但然后将其转换为MS。
在昨天和今天之间,我已经尝试了将近8个小时,但是我没有运气来查看互联网上的其他stackoverflow帖子和其他资源,例如 Angular的文档。
如果有人能帮助我,那将不胜感激。
I'm taking over a previous member's code which is very similar to the example HTML code and js functions provided here with a few small changes.
When I open the widget, I can change some attributes about a gateway (eg. high priority boolean, or inactivity timeout). The widget takes time in ms, which looks confusing for people when entering, so the previous member created some set times, relating to the times in ms, see image for visual. Example image of dropdown menu.
The HTML code for this is (I edited out parts for the other fields as not needed):
<form #editEntityForm="ngForm" [formGroup]="editEntityFormGroup"
(ngSubmit)="save()" class="edit-entity-form">
<div formGroupName="attributes" fxLayout="column" fxLayoutGap="8px">
<div fxLayout="row" fxLayoutGap="8px" fxLayout.xs="column" fxLayoutGap.xs="0">
<mat-form-field fxFlex class="mat-block">
<mat-label>Disconnection Timeout</mat-label>
<mat-select matInput formControlName="inactivityTimeout">
<mat-option value=1800000>30 min</mat-option>
<mat-option value=3600000>60 min</mat-option>
<mat-option value=7200000>120 min</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
</div>
</form>
The corresponding javascript function (from what I've been able to figure out) is:
function EditEntityDialogController(instance) {
let vm = instance;
vm.entityName = entityName;
vm.entityType = entityId.entityType;
vm.entitySearchDirection = {
to: "TO"
};
vm.attributes = {};
vm.oldRelationsData = [];
vm.relationsToDelete = [];
vm.entity = {};
vm.editEntityFormGroup = vm.fb.group({
entityName: ['', [vm.validators.required]],
entityType: [null],
entityLabel: [null],
type: ['', [vm.validators.required]],
attributes: vm.fb.group({
inactivityTimeout: [null, [vm.validators.pattern(/^-?[0-9]+$/)]],
}),
oldRelations: vm.fb.array([]),
relations: vm.fb.array([])
});
/*This function goes on but it is just a bunch of inner functions like
.save or .cancel*/
Although this setup isn't great, it is fine because it actually allows the output to be sent to the server attributes in ms, however, it sends it as a string instead of an integer even though the HTML code says value=180000 instead of value="180000". Image showing string type.
I'm trying to either get this current setup to output as an integer, or change it to a text input (which I've been able to do and it works, but only in ms) that displays in minutes but then gets converted to ms.
I've tried for nearly 8 hours between yesterday and today, but I've had no luck looking at other stackoverflow posts and other resources on the internet such as angular's documentation.
If anyone is able to help me, that would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果要使用值编号的字符串,则应将[]添加到Mat-Option中的'value':
这是一个简短的示例,其中有文本输入和发送数字的选择器:
html
js:
只需将此代码添加到自定义窗口行动。
If you want to use for value number instead string you should add [ ] to 'value' in mat-option:
here is a short example with text input and a selector that sends numbers:
HTML
JS:
just add this code to the custom widget action.