我正在尝试理解Typescript,但主要使用Dart。
我看到以下示例代码与我所做的相关
import {Component} from 'angular2/core';
import {Validators, MaxLengthValidator, Control, ControlGroup} from 'angular2/common';
import {isPresent} from 'angular2/src/facade/lang';
import {bootstrap} from 'angular2/platform/browser';
export class CustomValidators {
static minLengthWithDescription(minLength: number, desc: string): Function {
return (control: modelModule.Control): {[key: string]: any} => {
if (isPresent(Validators.required(control))) return null;
var v: string = control.value;
return v.length < minLength ?
{"minlength": {"requiredLength": minLength, "actualLength": v.length, "desc": desc}} :
null;
};
}
}
我能够理解大部分的代码,但是下面这段代码具体是做什么的呢?
return (control: modelModule.Control): {[key: string]: any} =>
有谁能够将这个小类转换成Dart语言的人可以吗?
谢谢
modelModule
是从import 'package:angular2/src/common/forms/model.dart' show Control
导入的model
的别名。我不明白为什么作者必须直接引用src。也许TypeScript强制执行这个规定。 - st_clair_clarkesrc/
,要么就是一个“bug”。 - Günter Zöchbauer