我有如下所示的架构对象
schedule: [{
time: {
type: Date,
required: true
}
}]
Run Code Online (Sandbox Code Playgroud)
当我尝试在邮递员中发布数据时
"schedule":[
{
"time":"18:00:00"
}]
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
验证失败:schedule.1.time:值“12:00:00”的转换为日期失败
如果我定义type为String,一切正常。
我认为我定义接受时间的类型是错误的。任何人都可以帮助我找到更好的方法来定义对象类型
我有一个服务,其方法如下:
getTotalCountries() {
this.http.get("country").subscribe((response) => {
console.log(response.json());//it is displaying all the data which is return by API
return response.json();
});
}
Run Code Online (Sandbox Code Playgroud)
以类似的方式,我在组件中具有如下功能:
public users: any
countCountry() {
this.count=this.user.getTotalCountries();
console.log(this.count) //it is not returning any data;
}
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚为什么它不返回component.ts. 有人可以帮我吗?