我的表单未同步。我希望输入文件。如果我在该输入中添加“ required”属性,即使文件已上传,它也会显示弹出所需的消息。如果我忽略“ required”属性,并且在kendoUpload配置中将验证定义为“ minFileSize:1”,则仅在文件上传后做出反应,而忽略提交表单后的验证。
interface IService {
doLogic();
}
@Injectable()
export class LocationService implements IService {
doLogic() {
console.log('service goes here...');
}
}
export class ParentComponent {
constructor(public locationService?: IService) {
}
}
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent extends ParentComponent {
constructor(locationService: LocationService) {
super(locationService);
this.locationService!.doLogic();
}
}
答案 0 :(得分:0)
请勿使用“必需”属性,而应使用其他属性,例如validateMessage
您可以使用以下规则:
rules: {
upload: function(input) {
if (input[0].type == "file" && input.is("[validationMessage]")) {
var len = input.closest(".k-upload").find(".k-file").length;
return len > 0;
}
return true;
}