• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript schematics.addModuleImportToRootModule函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: return

  return (host: Tree) => {
    const workspace = getWorkspace(host);
    const project = getProjectFromWorkspace(workspace, options.project);
    const appModulePath = getAppModulePath(host, getProjectMainFile(project));

    if (options.animations) {
      // In case the project explicitly uses the NoopAnimationsModule, we should print a warning
      // message that makes the user aware of the fact that we won't automatically set up
      // animations. If we would add the BrowserAnimationsModule while the NoopAnimationsModule
      // is already configured, we would cause unexpected behavior and runtime exceptions.
      if (hasNgModuleImport(host, appModulePath, noopAnimationsModuleName)) {
        return console.warn(red(`Could not set up "${bold(browserAnimationsModuleName)}" ` +
            `because "${bold(noopAnimationsModuleName)}" is already imported. Please manually ` +
            `set up browser animations.`));
      }

      addModuleImportToRootModule(host, browserAnimationsModuleName,
          '@angular/platform-browser/animations', project);
    } else if (!hasNgModuleImport(host, appModulePath, browserAnimationsModuleName)) {
      // Do not add the NoopAnimationsModule module if the project already explicitly uses
      // the BrowserAnimationsModule.
      addModuleImportToRootModule(host, noopAnimationsModuleName,
        '@angular/platform-browser/animations', project);
    }

    return host;
  };
开发者ID:Nodarii,项目名称:material2,代码行数:27,代码来源:setup-project.ts


示例2: return

  return (tree: Tree, context: SchematicContext) => {
    const project = getProject(tree, options.project);
    const appModulePath = getAppModulePath(tree, getProjectMainFile(project));
    const browserAnimationsModuleName = 'BrowserAnimationsModule';
    const noopAnimationsModuleName = 'NoopAnimationsModule';
    const animationsPackage = '@angular/platform-browser/animations';

    if (options.animations) {
      // In case the project explicitly uses the NoopAnimationsModule, we should print a warning
      // message that makes the user aware of the fact that we won't automatically set up
      // animations. If we would add the BrowserAnimationsModule while the NoopAnimationsModule
      // is already configured, we would cause unexpected behavior and runtime exceptions.
      if (hasNgModuleImport(tree, appModulePath, noopAnimationsModuleName)) {
        return context.logger.warn(red(`Could not set up "${bold(browserAnimationsModuleName)}" ` +
          `because "${bold(noopAnimationsModuleName)}" is already imported. Please manually ` +
          `set up browser animations.`));
      }

      addModuleImportToRootModule(tree, browserAnimationsModuleName, animationsPackage, project);
    } else if (!hasNgModuleImport(tree, appModulePath, browserAnimationsModuleName)) {
      // Do not add the NoopAnimationsModule module if the project already explicitly uses
      // the BrowserAnimationsModule.
      addModuleImportToRootModule(tree, noopAnimationsModuleName, animationsPackage, project);
    }
  }
开发者ID:kevinheader,项目名称:nebular,代码行数:25,代码来源:index.ts


示例3: addModuleImportToApptModule

function addModuleImportToApptModule(host: Tree, moduleName: string, src: string,
                                     project: WorkspaceProject, appModulePath: string,
                                     options: Schema): void {
  if (hasNgModuleImport(host, appModulePath, moduleName)) {
    console.log(chalk.yellow(`Could not set up "${chalk.blue(moduleName)}" ` +
      `because "${chalk.blue(moduleName)}" is already imported. Please manually ` +
      `check "${chalk.blue(appModulePath)}" file.`));
    return;
  }
  addModuleImportToRootModule(host, moduleName, src, project);
}
开发者ID:SrgGs,项目名称:ng-zorro-antd,代码行数:11,代码来源:add-required-modules.ts


示例4: return

  return (host: Tree) => {
    const workspace = getWorkspace(host);
    const project = getProjectFromWorkspace(workspace, options.project);
    const appModulePath = getAppModulePath(host, getProjectMainFile(project));

    if (options.animations) {
      if (hasNgModuleImport(host, appModulePath, noopAnimationsModuleName)) {
        console.log();
        return console.log(chalk.yellow(`Could not set up "${chalk.blue(browserAnimationsModuleName)}" ` +
          `because "${chalk.blue(noopAnimationsModuleName)}" is already imported. Please manually ` +
          `set up browser animations.`));
      }
      addModuleImportToRootModule(host, browserAnimationsModuleName,
        animationsModulePath, project);
    } else if (!hasNgModuleImport(host, appModulePath, browserAnimationsModuleName)) {
      addModuleImportToRootModule(host, noopAnimationsModuleName,
        animationsModulePath, project);
    }

    return host;
  };
开发者ID:SrgGs,项目名称:ng-zorro-antd,代码行数:21,代码来源:add-animations-module.ts


示例5: it

    it('should not add NoopAnimationsModule if BrowserAnimationsModule is set up', () => {
      const workspace = getWorkspace(appTree);
      const project = getProjectFromWorkspace(workspace);

      // Simulate the case where a developer uses `ng-add` on an Angular CLI project which already
      // explicitly uses the `BrowserAnimationsModule`. It would be wrong to forcibly change
      // to noop animations.
      const fileContent = addModuleImportToRootModule(appTree, 'BrowserAnimationsModule',
          '@angular/platform-browser/animations', project);

      expect(fileContent).not.toContain('NoopAnimationsModule',
          'Expected the project app module to not import the "NoopAnimationsModule".');
    });
开发者ID:codef0rmer,项目名称:material2,代码行数:13,代码来源:index.spec.ts


示例6: registerAppRoutingModule

function registerAppRoutingModule(tree: Tree, projectName: string) {
  const project = getProject(tree, projectName);
  addModuleImportToRootModule(tree, 'AppRoutingModule', './app-routing.module', project);
}
开发者ID:kevinheader,项目名称:nebular,代码行数:4,代码来源:index.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript schematics.buildComponent函数代码示例发布时间:2022-05-28
下一篇:
TypeScript schematics.addModuleImportToModule函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap