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


TypeScript lang.isString函数代码示例

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


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

示例1: link

export function link(segment: RouteSegment, routeTree: RouteTree, urlTree: UrlTree,
                     change: any[]): UrlTree {
  if (change.length === 0) return urlTree;

  let startingNode;
  let normalizedChange;

  if (isString(change[0]) && change[0].startsWith("./")) {
    normalizedChange = ["/", change[0].substring(2)].concat(change.slice(1));
    startingNode = _findStartingNode(_findUrlSegment(segment, routeTree), rootNode(urlTree));

  } else if (isString(change[0]) && change.length === 1 && change[0] == "/") {
    normalizedChange = change;
    startingNode = rootNode(urlTree);

  } else if (isString(change[0]) && !change[0].startsWith("/")) {
    normalizedChange = ["/"].concat(change);
    startingNode = _findStartingNode(_findUrlSegment(segment, routeTree), rootNode(urlTree));

  } else {
    normalizedChange = ["/"].concat(change);
    startingNode = rootNode(urlTree);
  }

  let updated = _update(startingNode, normalizedChange);
  let newRoot = _constructNewTree(rootNode(urlTree), startingNode, updated);

  return new UrlTree(newRoot);
}
开发者ID:davewragg,项目名称:angular,代码行数:29,代码来源:link.ts

示例2: _update

function _update(node: TreeNode<UrlSegment>, changes: any[]): TreeNode<UrlSegment> {
  let rest = changes.slice(1);
  let outlet = _outlet(changes);
  let segment = _segment(changes);
  if (isString(segment) && segment[0] == "/") segment = segment.substring(1);

  // reach the end of the tree => create new tree nodes.
  if (isBlank(node)) {
    let urlSegment = new UrlSegment(segment, null, outlet);
    let children = rest.length === 0 ? [] : [_update(null, rest)];
    return new TreeNode<UrlSegment>(urlSegment, children);

    // different outlet => preserve the subtree
  } else if (outlet != node.value.outlet) {
    return node;

    // same outlet => modify the subtree
  } else {
    let urlSegment = isStringMap(segment) ? new UrlSegment(null, segment, null) :
                                            new UrlSegment(segment, null, outlet);
    if (rest.length === 0) {
      return new TreeNode<UrlSegment>(urlSegment, []);
    }

    return new TreeNode<UrlSegment>(urlSegment,
                                    _updateMany(ListWrapper.clone(node.children), rest));
  }
}
开发者ID:davewragg,项目名称:angular,代码行数:28,代码来源:link.ts

示例3: _outlet

function _outlet(changes: any[]): string {
  if (!isString(changes[0])) return null;
  let parts = changes[0].toString().split(":");
  return parts.length > 1 ? parts[0] : null;
}
开发者ID:davewragg,项目名称:angular,代码行数:5,代码来源:link.ts

示例4: _segment

function _segment(changes: any[]): any {
  if (!isString(changes[0])) return changes[0];
  let parts = changes[0].toString().split(":");
  return parts.length > 1 ? parts[1] : changes[0];
}
开发者ID:davewragg,项目名称:angular,代码行数:5,代码来源:link.ts


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