本文整理汇总了TypeScript中angular2/src/facade/collection.ListWrapper.forEachWithIndex方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ListWrapper.forEachWithIndex方法的具体用法?TypeScript ListWrapper.forEachWithIndex怎么用?TypeScript ListWrapper.forEachWithIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/src/facade/collection.ListWrapper
的用法示例。
在下文中一共展示了ListWrapper.forEachWithIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _genEventBinding
/** @internal */
_genEventBinding(eb: EventBinding): string {
let codes: String[] = [];
this._endOfBlockIdxs = [];
ListWrapper.forEachWithIndex(eb.records, (r, i) => {
let code;
if (r.isConditionalSkipRecord()) {
code = this._genConditionalSkip(r, this._names.getEventLocalName(eb, i));
} else if (r.isUnconditionalSkipRecord()) {
code = this._genUnconditionalSkip(r);
} else {
code = this._genEventBindingEval(eb, r);
}
code += this._genEndOfSkipBlock(i);
codes.push(code);
});
return `
if (eventName === "${eb.eventName}" && elIndex === ${eb.elIndex}) {
${codes.join("\n")}
}`;
}
示例2: resolvePath
function resolvePath(pathParts: string[]): string {
let result = [];
ListWrapper.forEachWithIndex(pathParts, (part, index) => {
switch (part) {
case '':
case '.':
if (index > 0) return;
break;
case '..':
if (index > 0 && result.length != 0) result.pop();
return;
}
result.push(part);
});
return result.join('/');
}
示例3: expect
.andCallFake((args: UiArguments, returnType: Type) => {
expect(args.method).toEqual(methodName);
if (isPresent(vals)) {
expect(args.args.length).toEqual(vals.length);
ListWrapper.forEachWithIndex(vals, (v, i) => {expect(v).toEqual(args.args[i].value)});
}
var promise = null;
if (isPresent(handler)) {
let givenValues = args.args.map((arg) => {arg.value});
if (givenValues.length > 0) {
promise = handler(givenValues);
} else {
promise = handler();
}
}
if (promise == null) {
promise = PromiseWrapper.wrap(() => {});
}
return promise;
});
示例4: locals
get locals(): {[key: string]: string} {
var varValues: {[key: string]: string} = {};
// TODO(tbosch): right now, the semantics of debugNode.locals are
// that it contains the variables of all elements, not just
// the given one. We preserve this for now to not have a breaking
// change, but should change this later!
ListWrapper.forEachWithIndex(
this._view.staticNodeDebugInfos,
(staticNodeInfo: StaticNodeDebugInfo, nodeIndex: number) => {
var vars = staticNodeInfo.varTokens;
StringMapWrapper.forEach(vars, (varToken, varName) => {
var varValue;
if (isBlank(varToken)) {
varValue = isPresent(this._view.allNodes) ? this._view.allNodes[nodeIndex] : null;
} else {
varValue = this._view.injectorGet(varToken, nodeIndex, null);
}
varValues[varName] = varValue;
});
});
StringMapWrapper.forEach(this._view.locals,
(localValue, localName) => { varValues[localName] = localValue; });
return varValues;
}
示例5: it
it('should iterate over an array passing values and indices', () => {
var record = [];
ListWrapper.forEachWithIndex(l, (value, index) => record.push([value, index]));
expect(record).toEqual([['a', 0], ['b', 1]]);
});
示例6: createPropertyRecords
export function createPropertyRecords(definition: ChangeDetectorDefinition): ProtoRecord[] {
var recordBuilder = new ProtoRecordBuilder();
ListWrapper.forEachWithIndex(definition.bindingRecords,
(b, index) => recordBuilder.add(b, definition.variableNames, index));
return coalesce(recordBuilder.records);
}