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


TypeScript StringMapWrapper.set方法代码示例

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


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

示例1: load

  load(template: ViewDefinition): Promise</*element*/ any> {
    if (isPresent(template.template)) {
      return PromiseWrapper.resolve(DOM.createTemplate(template.template));
    }
    var url = template.absUrl;
    if (isPresent(url)) {
      var promise = StringMapWrapper.get(this._htmlCache, url);

      if (isBlank(promise)) {
        // TODO(vicb): change error when TS gets fixed
        // https://github.com/angular/angular/issues/2280
        // throw new BaseException(`Failed to fetch url "${url}"`);
        promise = PromiseWrapper.then(this._xhr.get(url), html => {
          var template = DOM.createTemplate(html);
          return template;
        }, _ => PromiseWrapper.reject(new BaseException(`Failed to fetch url "${url}"`), null));

        StringMapWrapper.set(this._htmlCache, url, promise);
      }

      // We need to clone the result as others might change it
      // (e.g. the compiler).
      return promise.then((tplElement) => DOM.clone(tplElement));
    }

    throw new BaseException('View should have either the url or template property set');
  }
开发者ID:B-Thapa,项目名称:angular,代码行数:27,代码来源:template_loader.ts

示例2: it

 it('should merge values in provided dictionary', () => {
   var map = StringMapWrapper.create();
   StringMapWrapper.set(map, 'foo', 'bar');
   var headers = new Headers(map);
   expect(headers.get('foo')).toBe('bar');
   expect(headers.getAll('foo')).toEqual(['bar']);
 });
开发者ID:TedSander,项目名称:angular,代码行数:7,代码来源:headers_spec.ts

示例3:

 .then((_: any[]) => {
   let map = StringMapWrapper.create();
   for (let i = 0, n = names.length; i < n; i++) {
     StringMapWrapper.set(map, names[i], values[i]);
   }
   completer.resolve(map);
 }, completer.reject);
开发者ID:4vanger,项目名称:angular,代码行数:7,代码来源:user_metric.ts

示例4: buildMap

 function buildMap(values) {
   var res = StringMapWrapper.create();
   for (var i = 0; i < keys.length; ++i) {
     StringMapWrapper.set(res, keys[i], values[i]);
   }
   return res;
 }
开发者ID:188799958,项目名称:angular,代码行数:7,代码来源:change_detection_util.ts

示例5: eval

 eval(context, locals) {
   var res = StringMapWrapper.create();
   for (var i = 0; i < this.keys.length; ++i) {
     StringMapWrapper.set(res, this.keys[i], this.values[i].eval(context, locals));
   }
   return res;
 }
开发者ID:CADBOT,项目名称:angular,代码行数:7,代码来源:ast.ts

示例6: setterFactory

export function setterFactory(property: string): Function {
  var setterFn, styleParts, styleSuffix;
  if (StringWrapper.startsWith(property, ATTRIBUTE_PREFIX)) {
    setterFn = attributeSetterFactory(StringWrapper.substring(property, ATTRIBUTE_PREFIX.length));
  } else if (StringWrapper.startsWith(property, CLASS_PREFIX)) {
    setterFn = classSetterFactory(StringWrapper.substring(property, CLASS_PREFIX.length));
  } else if (StringWrapper.startsWith(property, STYLE_PREFIX)) {
    styleParts = property.split(STYLE_SEPARATOR);
    styleSuffix = styleParts.length > 2 ? ListWrapper.get(styleParts, 2) : '';
    setterFn = styleSetterFactory(ListWrapper.get(styleParts, 1), styleSuffix);
  } else if (StringWrapper.equals(property, 'innerHtml')) {
    if (isBlank(innerHTMLSetterCache)) {
      innerHTMLSetterCache = (el, value) => DOM.setInnerHTML(el, value);
    }
    setterFn = innerHTMLSetterCache;
  } else {
    property = resolvePropertyName(property);
    setterFn = StringMapWrapper.get(propertySettersCache, property);
    if (isBlank(setterFn)) {
      var propertySetterFn = reflector.setter(property);
      setterFn = function(receiver, value) {
        if (DOM.hasProperty(receiver, property)) {
          return propertySetterFn(receiver, value);
        }
      };
      StringMapWrapper.set(propertySettersCache, property, setterFn);
    }
  }
  return setterFn;
}
开发者ID:tavwizard,项目名称:angular,代码行数:30,代码来源:property_setter_factory.ts

示例7: createpreBuildObject

 function createpreBuildObject(eventName, eventHandler) {
   var handlers = StringMapWrapper.create();
   StringMapWrapper.set(handlers, eventName, eventHandler);
   var pv = new ProtoView(null, null, null);
   pv.eventHandlers = [handlers];
   var view = new View(pv, null, MapWrapper.create());
   return new PreBuiltObjects(view, null, null, null);
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:8,代码来源:element_injector_spec.ts

示例8: handler

 StringMapWrapper.forEach(binder.events, (eventMap, eventName) => {
   var handler = ProtoView.buildEventHandler(eventMap, binderIdx);
   StringMapWrapper.set(eventHandlers[binderIdx], eventName, handler);
   if (isBlank(elementInjector) || !elementInjector.hasEventEmitter(eventName)) {
     eventManager.addEventListener(element, eventName, (event) => {
       handler(event, view);
     });
   }
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:9,代码来源:view.ts

示例9: it

 it('should clear all values and re-set for the provided key', () => {
   var map = StringMapWrapper.create();
   StringMapWrapper.set(map, 'foo', 'bar');
   var headers = new Headers(map);
   expect(headers.get('foo')).toBe('bar');
   expect(headers.getAll('foo')).toEqual(['bar']);
   headers.set('foo', 'baz');
   expect(headers.get('foo')).toBe('baz');
   expect(headers.getAll('foo')).toEqual(['baz']);
 });
开发者ID:1186792881,项目名称:angular,代码行数:10,代码来源:headers_spec.ts

示例10: on

 on(el, evt, listener) {
   var listenersMap: StringMap<any, any> = el._eventListenersMap;
   if (isBlank(listenersMap)) {
     var listenersMap: StringMap<any, any> = StringMapWrapper.create();
     el._eventListenersMap = listenersMap;
   }
   var listeners = StringMapWrapper.get(listenersMap, evt);
   if (isBlank(listeners)) {
     listeners = ListWrapper.create();
   }
   ListWrapper.push(listeners, listener);
   StringMapWrapper.set(listenersMap, evt, listeners);
 }
开发者ID:CADBOT,项目名称:angular,代码行数:13,代码来源:parse5_adapter.ts


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