当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript MapWrapper.forEach方法代码示例

本文整理汇总了TypeScript中angular2/src/facade/collection.MapWrapper.forEach方法的典型用法代码示例。如果您正苦于以下问题:TypeScript MapWrapper.forEach方法的具体用法?TypeScript MapWrapper.forEach怎么用?TypeScript MapWrapper.forEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/src/facade/collection.MapWrapper的用法示例。


在下文中一共展示了MapWrapper.forEach方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: process

 process(parent, current, control) {
   if (current.ignoreBindings) {
     return ;
   }
   var attrs = current.attrs();
   var newAttrs = MapWrapper.create();
   MapWrapper.forEach(attrs, (attrValue, attrName) => {
     var bindParts = RegExpWrapper.firstMatch(BIND_NAME_REGEXP, attrName);
     if (isPresent(bindParts)) {
       if (isPresent(bindParts[1])) {
         this._bindProperty(bindParts[4], attrValue, current, newAttrs);
       } else if (isPresent(bindParts[2])) {
         var identifier = bindParts[4];
         var value = attrValue == '' ? '\$implicit' : attrValue;
         this._bindVariable(identifier, value, current, newAttrs);
       } else if (isPresent(bindParts[3])) {
         this._bindEvent(bindParts[4], attrValue, current, newAttrs);
       } else if (isPresent(bindParts[5])) {
         this._bindProperty(bindParts[5], attrValue, current, newAttrs);
       } else if (isPresent(bindParts[6])) {
         this._bindEvent(bindParts[6], attrValue, current, newAttrs);
       }
     } else {
       var expr = this._parser.parseInterpolation(attrValue, current.elementDescription);
       if (isPresent(expr)) {
         this._bindPropertyAst(attrName, expr, current, newAttrs);
       }
     }
   });
   MapWrapper.forEach(newAttrs, (attrValue, attrName) => {
     MapWrapper.set(attrs, attrName, attrValue);
   });
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:33,代码来源:property_binding_parser.ts

示例2: recognize

  /**
   * Given a URL, returns a list of `RouteMatch`es, which are partial recognitions for some route.
   *
   */
  recognize(url: string): List<RouteMatch> {
    var solutions = ListWrapper.create();

    MapWrapper.forEach(this.redirects, (target, path) => {
      // TODO: "/" redirect case
      if (StringWrapper.startsWith(url, path)) {
        url = target + StringWrapper.substring(url, path.length);
      }
    });

    MapWrapper.forEach(this.matchers, (pathRecognizer, regex) => {
      var match;
      if (isPresent(match = RegExpWrapper.firstMatch(regex, url))) {
        // TODO(btford): determine a good generic way to deal with terminal matches
        var matchedUrl = '/';
        var unmatchedUrl = '';
        if (url != '/') {
          matchedUrl = match[0];
          unmatchedUrl = StringWrapper.substring(url, match[0].length);
        }
        ListWrapper.push(solutions, new RouteMatch({
                           specificity: pathRecognizer.specificity,
                           handler: pathRecognizer.handler,
                           params: pathRecognizer.parseParams(url),
                           matchedUrl: matchedUrl,
                           unmatchedUrl: unmatchedUrl
                         }));
      }
    });

    return solutions;
  }
开发者ID:B-Thapa,项目名称:angular,代码行数:36,代码来源:route_recognizer.ts

示例3:

 ListWrapper.forEach(foundDirectiveIndices, (directiveIndex) => {
   var directive = this._directives[directiveIndex];
   var directiveBinderBuilder = elementBinder.bindDirective(directiveIndex);
   current.compileChildren = current.compileChildren && directive.compileChildren;
   if (isPresent(directive.properties)) {
     MapWrapper.forEach(directive.properties, (bindConfig, dirProperty) => {
       this._bindDirectiveProperty(dirProperty, bindConfig, current, directiveBinderBuilder);
     });
   }
   if (isPresent(directive.hostListeners)) {
     MapWrapper.forEach(directive.hostListeners, (action, eventName) => {
       this._bindDirectiveEvent(eventName, action, current, directiveBinderBuilder);
     });
   }
   if (isPresent(directive.hostActions)) {
     MapWrapper.forEach(directive.hostActions, (action, actionName) => {
       this._bindHostAction(actionName, action, current, directiveBinderBuilder);
     });
   }
   if (isPresent(directive.hostProperties)) {
     MapWrapper.forEach(directive.hostProperties, (hostPropertyName, directivePropertyName) => {
       this._bindHostProperty(hostPropertyName, directivePropertyName, current,
                              directiveBinderBuilder);
     });
   }
   if (isPresent(directive.hostAttributes)) {
     MapWrapper.forEach(directive.hostAttributes, (hostAttrValue, hostAttrName) => {
       this._addHostAttribute(hostAttrName, hostAttrValue, current);
     });
   }
   if (isPresent(directive.readAttributes)) {
     ListWrapper.forEach(directive.readAttributes,
                         (attrName) => { elementBinder.readAttribute(attrName); });
   }
 });
开发者ID:baraksu,项目名称:angular,代码行数:35,代码来源:directive_parser.ts

示例4: _createDirectiveRecords

  _createDirectiveRecords(bindings: List<BindingRecord>, boundElementIndex: number,
                          directiveBinders: List<renderApi.DirectiveBinder>,
                          allDirectiveMetadatas: List<renderApi.DirectiveMetadata>) {
    for (var i = 0; i < directiveBinders.length; i++) {
      var directiveBinder = directiveBinders[i];
      var directiveMetadata = allDirectiveMetadatas[directiveBinder.directiveIndex];

      // directive properties
      MapWrapper.forEach(directiveBinder.propertyBindings, (astWithSource, propertyName) => {
        // TODO: these setters should eventually be created by change detection, to make
        // it monomorphic!
        var setter = reflector.setter(propertyName);
        var directiveRecord = this._getDirectiveRecord(boundElementIndex, i, directiveMetadata);
        ListWrapper.push(bindings, BindingRecord.createForDirective(astWithSource, propertyName,
                                                                    setter, directiveRecord));
      });

      // host properties
      MapWrapper.forEach(directiveBinder.hostPropertyBindings, (astWithSource, propertyName) => {
        var dirIndex = new DirectiveIndex(boundElementIndex, i);
        ListWrapper.push(
            bindings, BindingRecord.createForHostProperty(dirIndex, astWithSource, propertyName));
      });
    }
  }
开发者ID:188799958,项目名称:angular,代码行数:25,代码来源:proto_view_factory.ts

示例5: _createDirectiveBinders

 _createDirectiveBinders(protoView, sortedDirectives) {
   for (var i = 0; i < sortedDirectives.renderDirectives.length; i++) {
     var renderDirectiveMetadata = sortedDirectives.renderDirectives[i];
     MapWrapper.forEach(renderDirectiveMetadata.propertyBindings, (astWithSource, propertyName) => {
       var setter = reflector.setter(propertyName);
       protoView.bindDirectiveProperty(i, astWithSource.ast, propertyName, setter);
     });
     MapWrapper.forEach(renderDirectiveMetadata.eventBindings, (astWithSource, eventName) => {
       protoView.bindEvent(eventName, astWithSource.ast, i);
     });
   }
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:12,代码来源:proto_view_factory.ts

示例6: processElement

  processElement(parent: CompileElement, current: CompileElement, control: CompileControl) {
    var attrs = current.attrs();
    var newAttrs = new Map();

    MapWrapper.forEach(attrs, (attrValue, attrName) => {

      attrName = this._normalizeAttributeName(attrName);

      var bindParts = RegExpWrapper.firstMatch(BIND_NAME_REGEXP, attrName);
      if (isPresent(bindParts)) {
        if (isPresent(bindParts[1])) {  // match: bind-prop
          this._bindProperty(bindParts[6], attrValue, current, newAttrs);

        } else if (isPresent(
                       bindParts[2])) {  // match: var-name / var-name="iden" / #name / #name="iden"
          var identifier = bindParts[6];
          var value = attrValue == '' ? '\$implicit' : attrValue;
          this._bindVariable(identifier, value, current, newAttrs);

        } else if (isPresent(bindParts[3])) {  // match: on-event
          this._bindEvent(bindParts[6], attrValue, current, newAttrs);

        } else if (isPresent(bindParts[4])) {  // match: onbubble-event
          this._bindEvent('^' + bindParts[6], attrValue, current, newAttrs);

        } else if (isPresent(bindParts[5])) {  // match: bindon-prop
          this._bindProperty(bindParts[6], attrValue, current, newAttrs);
          this._bindAssignmentEvent(bindParts[6], attrValue, current, newAttrs);

        } else if (isPresent(bindParts[7])) {  // match: [(expr)]
          this._bindProperty(bindParts[7], attrValue, current, newAttrs);
          this._bindAssignmentEvent(bindParts[7], attrValue, current, newAttrs);

        } else if (isPresent(bindParts[8])) {  // match: [expr]
          this._bindProperty(bindParts[8], attrValue, current, newAttrs);

        } else if (isPresent(bindParts[9])) {  // match: (event)
          this._bindEvent(bindParts[9], attrValue, current, newAttrs);
        }
      } else {
        var expr = this._parser.parseInterpolation(attrValue, current.elementDescription);
        if (isPresent(expr)) {
          this._bindPropertyAst(attrName, expr, current, newAttrs);
        }
      }
    });

    MapWrapper.forEach(newAttrs, (attrValue, attrName) => { attrs.set(attrName, attrValue); });
  }
开发者ID:KenWilliamson,项目名称:Angular2HostedMobileApp,代码行数:49,代码来源:property_binding_parser.ts

示例7: dispatchEvent

 // implementation of EventDispatcher#dispatchEvent
 // returns false if preventDefault must be applied to the DOM event
 dispatchEvent(elementIndex: number, eventName: string, locals: Map<string, any>): boolean {
   // Most of the time the event will be fired only when the view is in the live document.
   // However, in a rare circumstance the view might get dehydrated, in between the event
   // queuing up and firing.
   var allowDefaultBehavior = true;
   if (this.hydrated()) {
     var elBinder = this.proto.elementBinders[elementIndex];
     if (isBlank(elBinder.hostListeners)) return allowDefaultBehavior;
     var eventMap = elBinder.hostListeners[eventName];
     if (isBlank(eventMap)) return allowDefaultBehavior;
     MapWrapper.forEach(eventMap, (expr, directiveIndex) => {
       var context;
       if (directiveIndex === -1) {
         context = this.context;
       } else {
         context = this.elementInjectors[elementIndex].getDirectiveAtIndex(directiveIndex);
       }
       var result = expr.eval(context, new Locals(this.locals, locals));
       if (isPresent(result)) {
         allowDefaultBehavior = allowDefaultBehavior && result == true;
       }
     });
   }
   return allowDefaultBehavior;
 }
开发者ID:188799958,项目名称:angular,代码行数:27,代码来源:view.ts

示例8: resolve

  /**
   * Returns the {@link View} for a component:
   * - Set the {@link View} to the overridden view when it exists or fallback to the default
   * `TemplateResolver`,
   *   see `setView`.
   * - Override the directives, see `overrideViewDirective`.
   * - Override the @View definition, see `setInlineTemplate`.
   *
   * @param component
   * @returns {ViewDefinition}
   */
  resolve(component: Type): View {
    var view = MapWrapper.get(this._viewCache, component);
    if (isPresent(view)) return view;

    view = MapWrapper.get(this._views, component);
    if (isBlank(view)) {
      view = super.resolve(component);
    }

    var directives = view.directives;
    var overrides = MapWrapper.get(this._directiveOverrides, component);

    if (isPresent(overrides) && isPresent(directives)) {
      directives = ListWrapper.clone(view.directives);
      MapWrapper.forEach(overrides, (to, from) => {
        var srcIndex = directives.indexOf(from);
        if (srcIndex == -1) {
          throw new BaseException(
              `Overriden directive ${stringify(from)} not found in the template of ${stringify(component)}`);
        }
        directives[srcIndex] = to;
      });
      view = new View(
          {template: view.template, templateUrl: view.templateUrl, directives: directives});
    }

    var inlineTemplate = MapWrapper.get(this._inlineTemplates, component);
    if (isPresent(inlineTemplate)) {
      view = new View({template: inlineTemplate, templateUrl: null, directives: view.directives});
    }

    MapWrapper.set(this._viewCache, component, view);
    return view;
  }
开发者ID:AsherBarak,项目名称:angular,代码行数:45,代码来源:template_resolver_mock.ts

示例9: _forEach

 _forEach(obj, fn) {
   if (obj instanceof Map) {
     MapWrapper.forEach(obj, fn);
   } else {
     StringMapWrapper.forEach(obj, fn);
   }
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:7,代码来源:keyvalue_changes.ts

示例10: parseHostConfig

  static parseHostConfig(host?: Map<string, string>): StringMap<string, Map<string, string>> {
    let hostListeners = MapWrapper.create();
    let hostProperties = MapWrapper.create();
    let hostAttributes = MapWrapper.create();
    let hostActions = MapWrapper.create();

    if (isPresent(host)) {
      MapWrapper.forEach(host, (value: string, key: string) => {
        var matches = RegExpWrapper.firstMatch(hostRegExp, key);
        if (isBlank(matches)) {
          MapWrapper.set(hostAttributes, key, value);
        } else if (isPresent(matches[1])) {
          MapWrapper.set(hostProperties, matches[1], value);
        } else if (isPresent(matches[2])) {
          MapWrapper.set(hostListeners, matches[2], value);
        } else if (isPresent(matches[3])) {
          MapWrapper.set(hostActions, matches[3], value);
        }
      });
    }

    return {
      hostListeners: hostListeners, hostProperties: hostProperties, hostAttributes: hostAttributes,
          hostActions: hostActions
    }
  }
开发者ID:amzinino,项目名称:angular,代码行数:26,代码来源:api.ts


注:本文中的angular2/src/facade/collection.MapWrapper.forEach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。