本文整理汇总了TypeScript中angular2/forms.Control类的典型用法代码示例。如果您正苦于以下问题:TypeScript Control类的具体用法?TypeScript Control怎么用?TypeScript Control使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Control类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("should be false after changing the value of the control", () => {
var c = new Control('value');
var g = new ControlGroup({"one": c});
c.updateValue('new value');
expect(g.pristine).toEqual(false);
});
示例2: it
it("should be false after changing the value of the control", () => {
var c = new Control(1);
var a = new ControlArray([c]);
c.updateValue('new value');
expect(a.pristine).toEqual(false);
});
示例3: it
it("should run the validator when the value changes", () => {
var a = new ControlArray([]);
var c = new Control(null, Validators.required);
a.push(c);
expect(a.valid).toBe(false);
c.updateValue("some value");
expect(a.valid).toBe(true);
expect(a.errors).toBe(null);
});
示例4: it
it("should run the validator with the value changes", () => {
var c = new Control(null, Validators.required);
var g = new ControlGroup({"one": c});
c.updateValue("some value");
expect(g.valid).toEqual(true);
expect(g.errors).toEqual(null);
});
示例5: describe
describe("dirty", () => {
var c: Control;
var a: ControlArray;
beforeEach(() => {
c = new Control('value');
a = new ControlArray([c]);
});
it("should be false after creating a control", () => { expect(a.dirty).toEqual(false); });
it("should be false after changing the value of the control", () => {
c.markAsDirty();
expect(a.dirty).toEqual(true);
});
});
示例6: addTodo
addTodo(event, todo) {
event.preventDefault(); // prevent native page refresh
this.todoService.add(todo);
// update the view/model
this.todoInput.updateValue('');
}