我想要pipe一个反应形式的表格组。
然后我想对这组单独的控件进行一些检查。
这是我定义表单的方式
myForm = this.formBuilder.group({
myFormNameDrop: this.formBuilder.group({
myName:['',Validators.required],
myDrop:['era']
}),
style:[''],
userId:[this.user_id]
});
Run Code Online (Sandbox Code Playgroud)
这就是pipe我试图创造的
this.results = this.myForm.value.myFormNameDrop.valueChanges.pipe(
debounceTime(400),
distinctUntilChanged(),
filter(formdata => formdata.myName.length > 0),
switchMap( formdata => this.shoesService.details(formdata.myName)),
shareReplay(1)
);//pipe
Run Code Online (Sandbox Code Playgroud)
我有两个错误。
TypeError: Cannot read property 'pipe' of undefined有关this.results = this.myForm.value.myFormNameDrop.valueChanges.pipe(
并且 VS 代码显示有关以下内容的警告filter(formdata => formdata.myName.length > 0),:myName类型上不存在属性'{}'
在这种情况下,我如何访问 formGroups 和 formGroups 的控件?我使用角度 6
谢谢
我是 child_process 的新手,我想尝试一下它的功能。
有什么方法可以使用 spawn 将函数和参数传递给 python 文件(或者 exec 或 execFile 是 spawn 不能做到的)?
我想做类似(伪代码)
spawnORexecORexefile (python path/to/python/file function [argument1, argument2] )
Run Code Online (Sandbox Code Playgroud)
或者可能
spawnORexecORexefile (python path/to/python/file function(argument1, argument2) )
Run Code Online (Sandbox Code Playgroud)
请解释一下,也许举个例子,因为我是新手
我现在是怎么做的?
在节点
var process = spawn('python', [path/to/pythonFile.py, 50, 60] );
Run Code Online (Sandbox Code Playgroud)
在 pythonFile.py
import sys
import awesomeFile
hoodie = int(sys.argv[1])
shoe = int(sys.argv[2])
awesomeFile.doYourMagic().anotherThing(hoodie, shoe)
Run Code Online (Sandbox Code Playgroud)
如您所见,从节点,我将数据发送到pythonFile,然后发送awesomeFile到特定函数
我想“切断中间人”并删除pythonFile节点并将数据直接发送到awesomeFile文件到特定功能。这就是为什么我要问
谢谢
我通过使用highcharts-vue在 Vue 应用程序中使用 Highcharts
我正在像这样设置我的模板
<highcharts class="vessChart" ref="chart" style="width:100%" :callback="chartcallback" :options="options" ></highcharts>
Run Code Online (Sandbox Code Playgroud)
然后我在 Vue 中设置图表的选项
yAxis:[],
series:[],
background:[],
options: {
chart: {
borderWidth: 1,
marginLeft: 40,
marginRight: 2,
type:'line',
zoomType: 'x',
title: {
text: ''
},
panning:true
/*backgroundColor:'lightgrey'*/
},
title: {
text: ''
},
pane:{
background:[]
},
time:{
useUTC:true
},
credits:{
enabled:false
},
tooltip: {
shared: true
},
title:{
text:null
},
rangeSelector: {
inputEnabled: false
},
xAxis:{
type:'datetime',
title:
{
align:'high'
},
labels: {
padding: 50,
format: '{value:%e …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的节点项目中设置续集,现在我有
//sequelize init
const { DataTypes } = Sequelize;
const sequelize = new Sequelize({
database: database,
username: user,
host: server,
password: password,
dialect: 'mssql',
dialectOptions: {
options: {
useUTC: true,
dateFirst: 1,
}
},
define:{
timestamps:false,
paranoid:false,
freezeTableName: true
}
});
//and my Model
const User= sequelize.define('User', {
// attributes
id: {
field:'Id',
type: Sequelize.INTEGER,
allowNull: false,
primaryKey: true
} ,
startTime: {
field:'startTime',
type: Sequelize.DATE
}
});
Run Code Online (Sandbox Code Playgroud)
我尝试设置version:true以启用乐观锁定
我把它放在模型中
const Vessel = sequelize.define('FDMData', {
// attributes …Run Code Online (Sandbox Code Playgroud) 我尝试创建一个UI,其中有一个带有几个文本字段的表单,a input type="file"和a div可以删除要与表单其余部分一起上传的图像.
我的目标/逻辑
使用相同的方法div来删除图像或单击它并打开文件夹资源管理器,如input type="file"行为.在小屏幕中启用点击是有意义的,实际上不可能"拖放".并且由于input type="file"表格中已经有一个没有理由从中获取图像div并将其附加到表格等等.我尝试拍摄掉的图像div,将其设置为值input type="file"并提交形成一次.(如果用户点击了div,那么input type="file"已经有了一个值,所以我可以再次自由提交表单).
这是代码
<div id="imageDrop" (click)='imageInput.click()' (drop)="drop($event)" (dragover)="allowDrop($event)" #imageDrop>
</div>
<input type="file" formControlName="imageInput" required #imageInput id="imageInput" (change)='imageChange($event)' > <!-- use css to hide it -->
Run Code Online (Sandbox Code Playgroud)
所以,当imageDrop点击时,实际上调用imageChangevia(click)='imageInput.click()'
这是组件中的打字稿.
//imageUpload is the name of the reactive form
acceptedImageTypes = {'image/png': true,'image/jpeg': true,'image/gif': true};
@ViewChild('imageDrop') imageDrop;
allowDrop(e) {
e.preventDefault();
}
drop(e) …Run Code Online (Sandbox Code Playgroud) file-upload image-uploading angular angular-reactive-forms angular6
我有一个不属于表单的单选按钮列表。我想根据一个值将其中一个设置为 true。
然后,当另一个人被点击时,除了被点击的那个之外,所有其他人都被设置为 false。
单选按钮列表是动态的,由 a ngFor,
我有类似的东西
<div *ngFor='let item of array;let i = index'>
<input type="radio" [checked]=false (click)='radioChecked(item.id,i)' > <input type="text" value='{{item.name}}' > <button type="button" >save</button>
</div>
ngOnInit() {
this.myService.getNumber(id).subscribe((data) =>{
//when the page loads, set one of radiobuttons to true
//somehow get the id and set to true, no standard is, since dynamic list
radioId.value = true;
})
}
radioChecked(id, i){
//turn all the others to false, except this one
}
Run Code Online (Sandbox Code Playgroud)
由于这不是表单并且没有标准行,所以我可以有一个 id,我该怎么做?我使用角度 6
谢谢
我正在使用角度6
我的HTML是
<form [formGroup]="myForm" >
<label>
<input type="text" formControlName="name" placeholder="name" required autofocus >
</label>
<label>
<select name="drop" formControlName="drop">
<option value="developer"selected >developer</option>
<option value="designer">designer</option>
<option value="admin">admin</option>
</select>
</label>
</form>
Run Code Online (Sandbox Code Playgroud)
即使我selected在option页面首次加载时在“开发人员”中进行设置,也未选择“开发人员”。我想这是一个小角度的错误,无法正确呈现html,因此我在定义表单时放入了组件:
myForm = this.formBuilder.group({
name:['',Validators.required],
drop:['developer']
});
Run Code Online (Sandbox Code Playgroud)
而且有效。
真正奇怪的是,当我this.myForm.reset();在另一个位于窗体外部的按钮内执行操作时,“名称”应为空,但下拉列表也完全为空,只是空白,但应显示“ developer”,对吗?
该按钮隐藏了一些元素,应该重置表单,它在表单外部并且确实
getOtherData(id){
this.myForm.reset();
Run Code Online (Sandbox Code Playgroud)
这行不通,所以我必须做
this.myForm.setValue({
name: '',
drop: 'developer'
});
Run Code Online (Sandbox Code Playgroud)
为了实际重置表格。这是怎么错的select用组合reset?我想使用reset一次并完全重置表单,而不会出现“ hacks”,该怎么办?
谢谢
我刚刚开始在我的angular 6中使用openlayers 5,并且按照本教程进行操作,同时也在研究这个SO问题。我的角度分量现在有
import ol-map from 'ol/map';
import ol-xyz from 'ol/source/xyz';
import ol-tile from 'ol/layer/tile';
import ol-view from 'ol/View';
import * as ol-proj from 'ol/proj';
Run Code Online (Sandbox Code Playgroud)
在我班上
olmap: ol-map;
source: ol-xyz;
layer: ol-tile;
view: ol-view;
Run Code Online (Sandbox Code Playgroud)
然后在我的 ngOnInit
this.source = new ol-xyz({
url: 'https://api.tiles.mapbox.com/v4/mapbox.light/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw'
});
this.layer = new ol-tile({
source: this.source
});
this.view = new ol-view({
center: ol-proj.fromLonLat([6.661594, 50.433237]),
zoom: 3,
});
this.olmap = new ol-map({
target: 'map',
layers: [this.layer],
view: this.view
});
Run Code Online (Sandbox Code Playgroud)
这可行,但我不了解openlayers的样式。我将缩放按钮作为简单,无样式的按钮放在地图下面div。我在这里想念什么?如何插入opelayers CSS样式?
谢谢
我使用 vuetify v-autocomplete,我希望它在每次选择或取消选择后关闭下拉菜单。到目前为止,这是我的代码
<v-autocomplete
v-model="ddselect"
:items="dditems"
@change="ddchange"
tags
ref="ddselectRef"
multiple
dense
disable-lookup
return-object
></v-autocomplete>
Run Code Online (Sandbox Code Playgroud)
然后我看v-model, 基于这里的例子
ddselect: {
handler: function() {
setTimeout(() => {
this.$refs.ddselectRef.menuIsActive = false;
}, 50);
},
deep: true,
immediate: true
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用。
我也尝试过使用菜单道具
<v-autocomplete
v-model="ddselect"
:items="dditems"
@change="ddchange"
tags
ref="ddselectRef"
multiple
dense
disable-lookup
return-object
:menu-props="{ closeOnClick:true }"
></v-autocomplete>
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
vue 3.9.3 与 vuetify 2.2.12
谢谢
即使“日期”是int,它也代表 yyyy mm dd 日期。我正在尝试SELECT按日期写一个订单,当它是 BC=true 时它是desc,所以日期将按正确的顺序 -500 01 02 然后 -500 01 03 (yyyy mm dd)
以及什么时候是 BC=false是asc,所以日期将再次按正确顺序排列 1500 01 02,然后是 150 01 03 (yyyy mm dd)
我想出了这个SELECT * FROM test ORDER BY bc=true desc, bc=false asc;在 BC 日期上效果很好的方法,但它会翻转 AD 日期(15000103 然后是 15000102,这是错误的)。
我知道有date可用的类型,但我希望它可以作为 BC 确切日期的 hack。
如何SELECT根据 BC 布尔列更改日期以正确排序?
谢谢
angular ×5
angular6 ×5
node.js ×2
vue.js ×2
angular-pipe ×1
css ×1
file-upload ×1
forms ×1
highcharts ×1
javascript ×1
openlayers ×1
openlayers-5 ×1
postgresql ×1
python ×1
radio-button ×1
sequelize.js ×1
sql ×1
sql-order-by ×1
vuetify.js ×1