我正在尝试以角度2创建按钮组件.在主机上,我必须设置动态生成的css类名.(取决于绑定属性)
主机上的'[ngClass]'不起作用.
我已经读过使用elementRef.nativeElement.classList.add(value)也不是最好的方法,因为webworkers(或左右)不支持classList
在主机上动态生成类的最佳选择是什么?
@Component({
selector: '[md-button]',
})
export class MdButton {
color_: string;
@Input
set color() {
this.color_ = value;
if (this.elementRef !== undefined) {
this.elementRef.nativeElement.classList.add('md-' + this.color_);
}
}
get color(): string {
return this.color_;
}
constructor(public elementRef: ElementRef){}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试将json数据发布到Java中的Controller.
这是我的控制器:
@ResponseBody
@RequestMapping(value="/{schoolId}", method=RequestMethod.POST)
public ClassGroupDTO addClassGroup(@RequestBody ClassGroupDTO classgroup, @PathVariable Integer schoolId) {
return partyService.addClassGroup(classgroup, schoolId);
}
Run Code Online (Sandbox Code Playgroud)
这就是ClassGroupDTO
public class ClassGroupDTO extends PartyDTO {
private PartyDTO titular;
private SiteDTO site;
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate startDate;
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDate endDate;
...
}
Run Code Online (Sandbox Code Playgroud)
我正在使用Jackson 2.4.3.
当给出字段startDate或endDate时,我无法发布数据.我尝试了几种格式发布.(我正在使用moment.js)
data.startDate = moment().toDate();
data.startDate = moment().toJSON();
data.startDate = moment().format("YYYY/MM/DD");
Run Code Online (Sandbox Code Playgroud)
每次收到错误请求错误.当我省略startDate或endDate时,会发布数据并触发控制器.
如何将javascript日期反序列化为java.time.LocalDate?