运行我的应用程序时出现此错误。这是我的申请的详细信息。
我已经尝试过清理缓存。
(即使使用Angular 7也确认了问题).让我们解决这个问题!
我正在使用HMR设置:https://github.com/angular/angular-cli/wiki/stories-configure-hmr from a ng newbuild build.
如果我更改任何组件并使其延迟加载,角度HMR将热重新加载所有内容,使页面同步更慢.
我知道这是因为它默认设置为console.log每个正在重新加载的模块,当我使用惰性路由时,它会记录所有内容.但是当我将该组件更改为非延迟加载时,它只记录一些小组件.
因此,当我使用HMR和懒惰路由时,我的应用程序需要几秒钟才能刷新.这很烦人.
有没有办法解决?
(懒惰的加载路线是通过这样的方式完成的)
// Main homepage
{
path: '',
loadChildren: './public/home/home.module#HomeModule'
},
// ...
Run Code Online (Sandbox Code Playgroud)
(只是一个例子,表明我正在以正确的方式加载)
这里有一些日志记录显示我懒惰加载时会发生什么 home.component.ts
// Everything here is normal, great!
[HMR] - ../../../../../src/app/public/home/home.component.html
log.js:23 [HMR] - ../../../../../src/app/public/home/home.component.ts
log.js:23 [HMR] - ../../../../../src/app/public/home/home.module.ts
log.js:23 [HMR] - ../../../../../src/app/public/home/home.routing.ts
// Everything below here is NOT normal, bad! All this is extra. These are my modules, yes, but all this needs to be loaded again?
log.js:23 …Run Code Online (Sandbox Code Playgroud) webpack-hmr angular-cli hot-module-replacement angular angular7
在Angular 2.0.0中,我正在测试使用Router的组件.但是我得到'提供的参数与呼叫目标的任何签名都不匹配'.错误.在spec.ts中的Visual Studio代码中,新的Router()以红色突出显示
如果有人能让我知道正确的语法是什么,我真的很感激?提前致谢.我的代码如下:
spec.ts
import { TestBed, async } from '@angular/core/testing';
import { NavToolComponent } from './nav-tool.component';
import { ComponentComm } from '../../shared/component-comm.service';
import { Router } from '@angular/router';
describe('Component: NavTool', () => {
it('should create an instance', () => {
let component = new NavToolComponent( new ComponentComm(), new Router());
expect(component).toBeTruthy();
});
});
Run Code Online (Sandbox Code Playgroud)
组件构造函数
constructor(private componentComm: ComponentComm, private router: Router) {}
Run Code Online (Sandbox Code Playgroud) 我有一个Angular PWA.它的服务工作者一直在完美地工作,直到我从Angular 5.0升级到7.2
升级后,我在/ ngsw/state中看到以下错误
驱动程序状态:SAFE_MODE(由于错误而导致初始化失败:违反Invariant(初始化):最新散列null没有已知的清单初始化/ <@https:// {{domain}} .com/ngsw-worker.js:2227:27已完成@https:// {{domain}} .com/ngsw-worker.js:1772:52)最新清单哈希:无最后更新检查:从不
应用背景
用于检查更新的代码
/ngsw/state
到目前为止我的研究和故障排除步骤
在Chrome中


在Microsoft边缘
我的想法和期望
我正在尝试通过新的"providedIn"属性提供解析服务.
这是我在受保护模块中使用的翻译解析器:
import { Injectable } from '@angular/core';
import { Observable , pipe } from 'rxjs';
import {map} from "rxjs/operators";
//This is causing: "WARNING in Circular dependency detected:"
import {ProtectedModule} from "../../../protected/protected.module";
import { HttpHandlerService } from '../../http/http-handler.service';
@Injectable({
providedIn: ProtectedModule //Over here (I need the import for this line)
})
export class TranslationsResolverService {
constructor(private _httpHandlerService : HttpHandlerService) { }
resolve(): any {
//Do Something...
}
}Run Code Online (Sandbox Code Playgroud)
我在受保护的路由模块中声明了翻译解析器服务:
import { NgModule } from '@angular/core';
import {RouterModule, Routes} from '@angular/router'; …Run Code Online (Sandbox Code Playgroud)我正在使用ViewChild,如下所示:
@ViewChild("InternalMedia") localStream;
@ViewChild("emoji") mEmoji;
Run Code Online (Sandbox Code Playgroud)
一直工作到angular-7.x
我将其升级到angular-8.x后,就开始出现以下错误
.../call_emoji/component.ts(41,4): error TS2554: Expected 2 arguments, but got 1.
Run Code Online (Sandbox Code Playgroud)
我检查了https://angular.io/api/core/ViewChild,并将其更改为
@ViewChild("InternalMedia",{static:false}) remoteStream;
Run Code Online (Sandbox Code Playgroud)
有用。我没有得到什么静态效果,像以前一样工作应该有什么价值?
我正在尝试在我现有的Angular 7.0.1项目(中等规模项目)中进行Web工作者设置.我在完成以下链接后进行了设置:
以下是我对每个文件的更改:
import 'zone.js';
import { enableProdMode } from '@angular/core';
import { bootstrapWorkerUi } from '@angular/platform-webworker';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
console.log("main.ts file loaded!");
bootstrapWorkerUi('webworker.js');
Run Code Online (Sandbox Code Playgroud)
import 'polyfills.ts';
import '@angular/core';
import '@angular/common';
console.log("workerLoader.ts file loaded!");
import { platformWorkerAppDynamic } from '@angular/platform-webworker-dynamic';
import { AppModule } from './app/app.module';
platformWorkerAppDynamic().bootstrapModule(AppModule);
Run Code Online (Sandbox Code Playgroud)
"projects": {
"[project name]": {
"architect": {
"build": { …Run Code Online (Sandbox Code Playgroud) I am using ng2-charts in Angular 7 app and having warning
WARNING in ./node_modules/ng2-charts/fesm5/ng2-charts.js 230:54-72 "export '??defineInjectable' was not found in '@angular/core'
error in VS Code
error in browser
What could be the reason and how to resolve it?
我有两个组件,一个父级和另一个子级。
HTML 部分
<div>
<div class="row col-md-12">
<div class="col-md-4">
<!-- Some HTML Code of Parent component over here -->
</div>
<div class="col-md-8">
<child-component></child-component>
</div>
</div>
<button class="button" (click)="reloadOnlyChild($event)">Reload Child</button>
</div>
Run Code Online (Sandbox Code Playgroud)
现在,单击此按钮后,我希望唯一的孩子重新加载或刷新。
TS部分
reloadOnlyChild(event){
// I want to reload the child from here.
}
Run Code Online (Sandbox Code Playgroud)
我在互联网上搜索,我得到的是 Vue 或 React,但不是 Angular。
angular7 ×10
angular ×8
angular6 ×4
typescript ×3
angular8 ×2
angular-cli ×1
angular5 ×1
ng2-charts ×1
unit-testing ×1
viewchild ×1
web-worker ×1
webpack ×1
webpack-hmr ×1