标签: angular-cli

在ng服务器上获取错误:ERROR in无法读取未定义的属性"listLazyRoutes"

当ng serve在命令行中运行angular-cli生成的项目时,我收到以下错误:

 ERROR in Cannot read property 'listLazyRoutes' of undefined
Run Code Online (Sandbox Code Playgroud)

有关如何修复此错误的任何想法?

angular-cli angular

14
推荐指数
2
解决办法
8333
查看次数

angular cli排除`ng test --code-coverage`的文件/目录

我正在运行以下命令进行单元测试并生成代码覆盖率报告.

ng test --code-coverage
Run Code Online (Sandbox Code Playgroud)

它工作正常并在coverage文件夹中编写代码覆盖率报告.

在这里我得到了所有文件和目录覆盖率报告

在此输入图像描述

但是我想排除特定的文件/目录src/app/quote/services/generated.怎么做?

karma-runner istanbul angular-cli angular

14
推荐指数
2
解决办法
1万
查看次数

Angular2(CLI)树抖动动态创建的NgModule

我认为在Angular-cli树抖动中排除组件的问题非常相似,但我似乎无法从中得到任何东西.

基本上我有一个动态组件工厂,如我如何使用/创建动态模板来编译动态组件与Angular 2.0?.

当我使用最新的Angular CLI和非生产设置构建它时,一切正常.但是,一旦我使用生产设置,我在尝试加载具有动态创建内容的页面时立即在浏览器中获得以下错误跟踪:

例外:找不到'e'的NgModule元数据.
ORIGINAL STACKTRACE:
main.dc05ae9 ... .bundle.js:格式:4731
错误:找不到'e'的NgModule元数据.
at t(vendor.c18e6df ... .bundle.js:格式化:76051)
at t.resolve(vendor.c18e6df ... .bundle.js:格式化:20624)
at t.getNgModuleMetadata(vendor.c18e6df ... .bundle.js:formatted: 20169)
在t._compileModuleAndAllComponents(vendor.c18e6df ... .bundle.js:格式化:40462)的t._loadModules(vendor.c18e6df ... .bundle.js:格式化:40474
)
at t.compileModuleAndAllComponentsSync(vendor.c18e6df ... .bundle. js:格式化:40436)
在e.createComponentFactory(main.dc05ae9 ... .bundle.js:格式:4789)

这是我的组件工厂类:

@Injectable()
export class DynamicTypeBuilder {    
  constructor() {
  }

  private _cacheOfFactories: {[templateKey: string]: ComponentFactory<any>} = {};
  private compiler: Compiler = new JitCompilerFactory([{useDebug: false, useJit: true}]).createCompiler();

  public createComponentFactory<COMPONENT_TYPE>(type: any, template: string, additionalModules: any[] = []): Observable<ComponentFactory<COMPONENT_TYPE>> {

    let …
Run Code Online (Sandbox Code Playgroud)

webpack angular-cli tree-shaking angular

14
推荐指数
1
解决办法
1248
查看次数

如何调用Angular-CLI .NET Core中的index.html?

我使用Visual Studio 2017构建了一个Angular-CLI .Net Core SPA

dotnet new angular -o my-new-app 
Run Code Online (Sandbox Code Playgroud)

我正在努力寻找的是在写入时默认调用文件夹index.html内部的内容ClientApp/src

http://localhost:57782
Run Code Online (Sandbox Code Playgroud)

startup.cs文件如下:

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.SpaServices.AngularCli;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace angular_cli
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //services.AddMvc();

            // In production, the Angular files will be …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc asp.net-core angular-cli

14
推荐指数
1
解决办法
2849
查看次数

我们如何在 Angular 中预加载字体?

我们应该像下面的代码一样在index.html文件中包含字体,rel="preload"还是我们可以在 Angular CLI 中配置它来预加载所有需要的字体?
请建议我一个更好的解决方案,因为我可以看到 Google 分析中建议的页面加载时间需要多秒。

<link rel="preload" href="./assets/fonts/Lato/Lato-Semibold.woff2" as="font" crossorigin>
<link rel="preload" href="./assets/fonts/Lato/Lato-Black.woff2" as="font" crossorigin>
<link rel="preload" href="./assets/fonts/Lato/Lato-Bold.woff2" as="font" crossorigin>
<link rel="preload" href="./assets/fonts/Lato/Lato-Heavy.woff2" as="font" crossorigin>
<link rel="preload" href="./assets/fonts/Lato/Lato-Medium.woff2" as="font" crossorigin>
<link rel="preload" href="./assets/fonts/Lato/Lato-Regular.woff2" as="font" crossorigin>
Run Code Online (Sandbox Code Playgroud)

html fonts preload angular-cli angular

14
推荐指数
1
解决办法
3354
查看次数

Ubuntu 16无法识别ng命令

目前尚未安装"ng"程序.您可以通过键入以下命令安装它:sudo apt install ng-common

我在安装过程中没有错误,我该如何解决?

编辑:当我尝试运行时会发生这种情况 ng new PROJECT_NAME

angular-cli angular

13
推荐指数
4
解决办法
1万
查看次数

在Ubuntu Zesty 17.04上安装Node 6.9

我想安装的最新版本NodeJS上Ubuntu Zesty 17.04.但无论是使用apt-get还是尝试从nodesource ppa下载它,我总是拥有版本4.7.2.

apt-get的

sudo apt-get update
sudo apt-get install nodejs npm
Run Code Online (Sandbox Code Playgroud)

节点PPA

curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
sudo apt-get update
apt-get install nodejs npm
Run Code Online (Sandbox Code Playgroud)

结果

$> node -v
v4.7.2
Run Code Online (Sandbox Code Playgroud)

我怎样才能获得NodeJS的6.9版本?

javascript ubuntu node.js npm angular-cli

13
推荐指数
2
解决办法
1万
查看次数

错误rxjs_Observable __.Observable.forkJoin不是函数?

我正在使用Rxjs中的angualr-cli应用程序.

在viewer.component.ts中

    //Other Imports
    import { Observable } from 'rxjs/Observable';
    //omitting for brevity
   export class ViewerComponent implements OnInit, AfterViewInit, OnDestroy {
    someFunction(someArg){
    //omitting for brevity
    let someArray: any = [];
    //Add some info
    Observable.forkJoin(someArray).subscribe(data => {
              //Do something with data
            });
    }
    //omitting for brevity
    }  
Run Code Online (Sandbox Code Playgroud)

我得到了错误

ERROR TypeError: __WEBPACK_IMPORTED_MODULE_2_rxjs_Observable__.Observable.forkJoin is not a function
    at ViewerComponent.webpackJsonp../src/app/component/viewer.component.ts.ViewerComponent.someFunction(http://localhost:4200/main.bundle.js:4022:73)
    at http://localhost:4200/main.bundle.js:3951:31
Run Code Online (Sandbox Code Playgroud)

但如果我Rxjs完全导入(import 'rxjs';)一切正常.没错.我似乎还明白了什么是必要的.我也尝试导入rxjs/Observable/forkjoin但没有任何可用的.

关于如何解决这个问题的任何指示.

fork-join rxjs5 angular-cli angular

13
推荐指数
1
解决办法
1万
查看次数

Angular 2单元测试错误无法获取未定义或空引用的属性'preventDefault'

我为一个组件创建了一系列单元测试.它最初失败了,因为我得到了上述错误,所以我拿出了event.defaultPrevented的东西,却没有真正知道它在做什么.

好吧,这修复了我的错误,但显然对UI行为产生了非常糟糕的副作用,所以我不得不把这些东西放回我的代码中.

所以,现在我回来修复我的单元测试.我怎样才能将事件内容模拟/注入我的单元测试中?

只是由Angular CLI删除的默认"应该创建"测试失败,这里是代码:

let component: MemberAddComponent;
let fixture: ComponentFixture<MemberAddComponent>;
let contractsService: ContractsService;
let notesService: NotesService;
let saveButton: any;

beforeEach(async(() => {
    let router = { navigate: jasmine.createSpy('navigate') };

    TestBed.configureTestingModule({
        imports: [
            HttpModule,
            FormsModule,
            ReactiveFormsModule,
            RouterTestingModule
        ],
        declarations: [
            MemberAddComponent,
            // lots more here
        ],
        providers: [
            AppDataService,
            ErrorService,
            {
                provide: ContractsService,
                useClass: MockContractsService
            },
            {
                provide: NotesService,
                useClass: MockNotesService
            }
        ]
    })
    .compileComponents();
}));

beforeEach(() => {
    fixture = TestBed.createComponent(MemberAddComponent);
    component = fixture.componentInstance;
    contractsService = fixture.debugElement.injector.get(ContractsService);
    saveButton = …
Run Code Online (Sandbox Code Playgroud)

unit-testing jasmine angular-cli angular

13
推荐指数
1
解决办法
888
查看次数

如何在DataTable按钮上放置一个Fontawesome图标? - 角度

我正在使用angular-fontawesome和datatables,我想在表格中创建一个按钮,但我想用fontawesome来放置一个图标而不是文本.我有以下代码:

this.dtOptions = {
    //...
    buttons: [
        //...
        {
            extend: 'pdf',
            text: '<fa-icon [icon]="faDownload"></fa-icon>'
        }
    ]           
};
Run Code Online (Sandbox Code Playgroud)

我知道我不会以这种方式加载图标的组件,但有没有办法在不必使用fontawesome css的情况下完成它?

datatables font-awesome angular-cli angular

13
推荐指数
2
解决办法
1703
查看次数