本文整理汇总了TypeScript中@proactive/extensions.ObservableArray.getValue方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ObservableArray.getValue方法的具体用法?TypeScript ObservableArray.getValue怎么用?TypeScript ObservableArray.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@proactive/extensions.ObservableArray
的用法示例。
在下文中一共展示了ObservableArray.getValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("for: bind to an observable array adding/removing", async (t) => {
const template = `<ul><li x-for:value="src" x-text="value"></li></ul>`;
const el = parse(template)[0] as HTMLElement;
const array = new ObservableArray([1, 3, 5]);
t.notThrows(() => ui.domManager.applyDirectives({ src: array }, el));
array.push(7);
t.is(el.children.length, array.getValue().length);
t.deepEqual(toArray(el.children).map((node) => parseInt(node.textContent || "")), array.getValue());
array.pop();
t.is(el.children.length, array.getValue().length);
t.deepEqual(toArray(el.children).map((node) => parseInt(node.textContent || "")), array.getValue());
array.shift();
t.is(el.children.length, array.getValue().length);
t.deepEqual(toArray(el.children).map((node) => parseInt(node.textContent || "")), array.getValue());
array.unshift(9);
t.is(el.children.length, array.getValue().length);
t.deepEqual(toArray(el.children).map((node) => parseInt(node.textContent || "")), array.getValue());
});
示例2: it
it("value: select multiple can be bound to an array", async (t) => {
const template = `<select multiple x-value="selected">
<option value="A">A</option>
<option value="B">B</option>
</select>`;
const selected = new ObservableArray<string>([]);
const el = parse(template)[0] as HTMLSelectElement;
const viewmodel = { selected };
ui.domManager.applyDirectives(viewmodel, el);
selected.push("A");
t.is(el.options[0].selected, true, "Dataflow.Out");
el.options[1].selected = true;
triggerEvent(el, "change");
t.is(selected.getValue().length, 2, "Dataflow.In");
});