我想知道如何从角度4的输入中获取值.我查看了有关角度的文档,关键事件的示例对我来说效果不好,我找不到合适的示例如何这样做,请帮助我
问题:我尝试读取输入的值,然后将值提交给另一个组件,该组件将值添加到选择标记(例如,将人员的姓名发送到选择标记的列表)
我正在寻找一种在验证消息中使用属性名称的正确方法,比如{min}
或{regexp}
.
我现在已经搜索了几次这个问题,显然没有本地方法可以做到这一点.
@NotNull(message = "The property {propertyName} may not be null.")
private String property;
Run Code Online (Sandbox Code Playgroud)
有没有人以前经历过这个,并设法找到解决方案?
更新1
使用自定义消息插补器应该是这样的:
public class CustomMessageInterpolator implements MessageInterpolator {
@Override
public String interpolate(String templateString, Context cntxt) {
return templateString.replace("{propertyName}", getPropertyName(cntxt));
}
@Override
public String interpolate(String templateString, Context cntxt, Locale locale) {
return templateString.replace("{propertyName}", getPropertyName(cntxt));
}
private String getPropertyName(Context cntxt) {
//TODO:
return "";
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个使用的iOS应用程序,sqlite3
我正面临多线程问题,使应用程序崩溃illegal multi-threaded access to database connection
.当然,这是因为我正在使用多线程; 问题是,我的sqlyte3实例配置为使用多线程:
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
Run Code Online (Sandbox Code Playgroud)
即使我使用多线程(sqlite3构建也使用多线程标志编译),当多个线程同时写入或读取数据库时,它会导致我的应用程序崩溃.
崩溃报告
Application Specific Information:
BUG IN CLIENT OF sqlite3.dylib: illegal multi-threaded access to database connection
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001823ed2fc
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [0]
Triggered by Thread: 12
Thread 12 Crashed:
0 libsqlite3.dylib 0x00000001823ed2fc sqlite3MutexMisuseAssert + 144 (sqlite3.c:23788)
1 libsqlite3.dylib 0x00000001823ed2ec sqlite3MutexMisuseAssert + 128 (once.h:84)
2 libsqlite3.dylib 0x000000018235248c sqlite3LockAndPrepare + 320 (sqlite3.c:23801) …
Run Code Online (Sandbox Code Playgroud) 我该如何检测模板中的道具变化(角度):
但是我不知道模具中的情况如何。
import { Component, Input, OnInit } from '@angular/core';
@Component({
selector: 'my-name',
template: `
<h2>First name: {{name}} ({{_name}})</h2>
`,
})
export class ChildComponent implements OnInit {
private _name: string;
constructor() {}
get name(): string {
// transform value for display
return this._name.toUpperCase();
}
@Input()
set name(name: string) {
console.log('prev value: ', this._name);
console.log('got name: ', name);
this._name = name;
}
ngOnInit() {
console.log('on init');
console.log(this._name);
}
}
Run Code Online (Sandbox Code Playgroud)
我需要检测属性更改
我想过滤一个包含零(0)的数组,同时捕获它们.
var arr1 = [-200, -163, -26, -4, 0, 7, 76];
var evens = arr1.filter(function(x) {
if (x % 2 === 0 || x === 0) {
return x;
}
})
console.log(evens);
Run Code Online (Sandbox Code Playgroud)
为什么我的'evens'阵列中没有归零?如果零不被归类为偶数,则不应该是我的
|| x===0
Run Code Online (Sandbox Code Playgroud)
声明抓零?
谢谢Brad
angular ×2
arrays ×1
components ×1
filter ×1
input ×1
ios ×1
java ×1
javascript ×1
sqlite ×1
stenciljs ×1
validation ×1