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


TypeScript lang.stringify函数代码示例

本文整理汇总了TypeScript中angular2/src/facade/lang.stringify函数的典型用法代码示例。如果您正苦于以下问题:TypeScript stringify函数的具体用法?TypeScript stringify怎么用?TypeScript stringify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: BaseException

 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;
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:7,代码来源:template_resolver_mock.ts

示例2: function

 setterFn = function(element, value) {
   if (_isValidAttributeValue(dashCasedAttributeName, value)) {
     DOM.setAttribute(element, dashCasedAttributeName, stringify(value));
   } else {
     if (isPresent(value)) {
       throw new BaseException("Invalid " + dashCasedAttributeName +
       " attribute, only string values are allowed, got '" + stringify(value) + "'");
     }
     DOM.removeAttribute(element, dashCasedAttributeName);
   }
 };
开发者ID:tavwizard,项目名称:angular,代码行数:11,代码来源:property_setter_factory.ts

示例3: _genMessage

 private static _genMessage(typeOrFunc, params: any[][]) {
   var signature = [];
   for (var i = 0, ii = params.length; i < ii; i++) {
     var parameter = params[i];
     if (isBlank(parameter) || parameter.length == 0) {
       signature.push('?');
     } else {
       signature.push(parameter.map(stringify).join(' '));
     }
   }
   return "Cannot resolve all parameters for '" + stringify(typeOrFunc) + "'(" +
          signature.join(', ') + "). " +
          "Make sure that all the parameters are decorated with Inject or have valid type annotations and that '" +
          stringify(typeOrFunc) + "' is decorated with Injectable.";
 }
开发者ID:844496869,项目名称:angular,代码行数:15,代码来源:reflective_exceptions.ts

示例4: it

 it('should create a ChangeDetectorDefinition for the root render proto view', () => {
   var renderPv = createRenderProtoView();
   var defs =
       getChangeDetectorDefinitions(bindDirective(MainComponent).metadata, renderPv, []);
   expect(defs.length).toBe(1);
   expect(defs[0].id).toEqual(`${stringify(MainComponent)}_comp_0`);
 });
开发者ID:lavinjj,项目名称:angular,代码行数:7,代码来源:proto_view_factory_spec.ts

示例5: factory

  factory(t: Type): Function {
    switch (t.length) {
      case 0:
        return function() { return new t(); };
      case 1:
        return function(a1) { return new t(a1); };
      case 2:
        return function(a1, a2) { return new t(a1, a2); };
      case 3:
        return function(a1, a2, a3) { return new t(a1, a2, a3); };
      case 4:
        return function(a1, a2, a3, a4) { return new t(a1, a2, a3, a4); };
      case 5:
        return function(a1, a2, a3, a4, a5) { return new t(a1, a2, a3, a4, a5); };
      case 6:
        return function(a1, a2, a3, a4, a5, a6) { return new t(a1, a2, a3, a4, a5, a6); };
      case 7:
        return function(a1, a2, a3, a4, a5, a6, a7) { return new t(a1, a2, a3, a4, a5, a6, a7); };
      case 8:
        return function(a1, a2, a3, a4, a5, a6, a7, a8) {
          return new t(a1, a2, a3, a4, a5, a6, a7, a8);
        };
      case 9:
        return function(a1, a2, a3, a4, a5, a6, a7, a8, a9) {
          return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9);
        };
      case 10:
        return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
          return new t(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
        };
    };

    throw new Error(
        `Cannot create a factory for '${stringify(t)}' because its constructor has more than 10 arguments`);
  }
开发者ID:Bogatinov,项目名称:angular,代码行数:35,代码来源:reflection_capabilities.ts

示例6: _buildRenderDirective

 _buildRenderDirective(directiveBinding) {
   var ann = directiveBinding.annotation;
   var renderType;
   var compileChildren = true;
   if ((ann instanceof Component) || (ann instanceof DynamicComponent)) {
     renderType = renderApi.DirectiveMetadata.COMPONENT_TYPE;
   } else if (ann instanceof Viewport) {
     renderType = renderApi.DirectiveMetadata.VIEWPORT_TYPE;
   } else if (ann instanceof Decorator) {
     renderType = renderApi.DirectiveMetadata.DECORATOR_TYPE;
     compileChildren = ann.compileChildren;
   }
   var setters = [];
   var readAttributes = [];
   ListWrapper.forEach(directiveBinding.dependencies, (dep) => {
     if (isPresent(dep.propSetterName)) {
       ListWrapper.push(setters, dep.propSetterName);
     }
     if (isPresent(dep.attributeName)) {
       ListWrapper.push(readAttributes, dep.attributeName);
     }
   });
   return new renderApi.DirectiveMetadata({
     id: stringify(directiveBinding.key.token),
     type: renderType,
     selector: ann.selector,
     compileChildren: compileChildren,
     events: isPresent(ann.events) ? MapWrapper.createFromStringMap(ann.events) : null,
     bind: isPresent(ann.bind) ? MapWrapper.createFromStringMap(ann.bind) : null,
     setters: setters,
     readAttributes: readAttributes
   });
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:33,代码来源:compiler.ts

示例7: _checkOverrideable

  /**
   * Once a component has been compiled, the AppProtoView is stored in the compiler cache.
   *
   * Then it should not be possible to override the component configuration after the component
   * has been compiled.
   *
   * @param {Type} component
   */
  _checkOverrideable(component: Type): void {
    var cached = MapWrapper.get(this._templateCache, component);

    if (isPresent(cached)) {
      throw new BaseException(`The component ${stringify(component)} has already been compiled, its configuration can not be changed`);
    }
  }
开发者ID:tavwizard,项目名称:angular,代码行数:15,代码来源:template_resolver_mock.ts

示例8: _readMetadata

function _readMetadata(componentType: Type) {
  let metadata = reflector.annotations(componentType).filter(f => f instanceof RoutesMetadata);
  if (metadata.length === 0) {
    throw new BaseException(
        `Component '${stringify(componentType)}' does not have route configuration`);
  }
  return metadata[0];
}
开发者ID:AwelEshetu,项目名称:angular,代码行数:8,代码来源:recognize.ts

示例9: it

 it('should not allow overriding a view after it has been resolved', () => {
   viewResolver.resolve(SomeComponent);
   expect(() => {
     viewResolver.setView(SomeComponent, new View({template: 'overridden template'}));
   })
       .toThrowError(
           `The component ${stringify(SomeComponent)} has already been compiled, its configuration can not be changed`);
 });
开发者ID:lavinjj,项目名称:angular,代码行数:8,代码来源:view_resolver_mock_spec.ts


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