以下是我的一段代码,为了简洁起见,我简化了代码。
ngOnInit() {
//intialize form fields
this.form = this.builder.group({
name: '',
age: '',
location: '',
});
//Call to the service
this.dataService.getDetails().subscribe(
(data) => {
this.dataArray = data;
if (this.dataArray[this.count].status === 'OK') {
let docs = {};
this.someService.getDocs(this.dataArray[this.count].id).subscribe(
(data) => {
docs = data;
console.log("docs: ", docs);
this.setFormValues(docs);//set form values
},
(err) => {
console.log(err);
console.log('Something happened');
}
);
}
},
(err) => {
console.log(err);
console.log('Something happened',err);
}
);
}
Run Code Online (Sandbox Code Playgroud)
现在,setFormValues()我已经打印了字段的值及其工作正常,但接下来当我尝试form使用setValue或将值绑定到 时patchValue,它根本不会form …
我List的N项目,我想这分List以连续的方式固定数目之间threads.
顺序我的意思是,我想传递1 to N/4给第一个thread,N/4 + 1 to N/2第二个线程和N/2+1 to N第三个thread,现在一旦所有的threads工作完成了,我想通知主要thread发送一些消息,说明所有处理都已完成.
到目前为止我所做的是我已经实施了 ExecutorService
我做了这样的事
ExecutorService threadPool = Executors.newFixedThreadPool(Number_of_threads);
//List of items List
List <items>itemList = getList();
for (int i = 0 i < Number_of_threads ;i++ ) {
//how to divide list here sequentially and pass it to some processor while will process those items.
Runnable processor = new Processor(Start, …Run Code Online (Sandbox Code Playgroud) 我正在尝试将所有key/value对加载到我的属性文件中。
一种方法是我使用@Value手动加载所有属性,但为此我应该知道所有键。
我无法执行此操作,因为将来可能会更改属性文件以包含更多key/value对,因此可能需要code再次修改以容纳它们。
第二种方法是,我应该了解一些如何加载属性文件并对其进行迭代以加载所有key/value对,而无需知道键。
说我有以下属性文件 sample.properties
property_set.name="Database MySQL"
db.name=
db.url=
db.user=
db.passwd=
property_set.name="Database Oracle"
db.name=
db.url=
db.user=
db.passwd=
Run Code Online (Sandbox Code Playgroud)
这是我想要做的
@Configuration
@PropertySource(value="classpath:sample.properties")
public class AppConfig {
@Autowired
Environment env;
@Bean
public void loadConfig(){
//Can I some how iterate over the loaded sampe.properties and load all
//key/value pair in Map<String,Map<String, String>>
// say Map<"Database MySQL", Map<key,vale>>
// I cannot get individual properties like env.getProperty("key");
// since I may not know all the …Run Code Online (Sandbox Code Playgroud) java ×2
angular ×1
angular6 ×1
concurrency ×1
properties ×1
spring ×1
spring-boot ×1
typescript ×1