小编sho*_*ish的帖子

Angular服务工作者在SAFE_MODE中

我有一个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)最新清单哈希:无最后更新检查:从不

应用背景

  • Angular版本是7.2.0
  • 服务工作者版本是7.2.0
  • 我使用SwUpdate服务手动检查更新.

用于检查更新的代码 /ngsw/state

到目前为止我的研究和故障排除步骤

在Chrome中

  • 服务工作者注册时没有任何错误
  • 我查看了网络选项卡,发现服务工作者永远不会下载'ngsw.json'.当应用程序在Angular 5.0中时,我看到'ngsw.json'被下载了

Screenshot1

  • 我看到这里报道了同样的问题.我在这里看不到任何适当的解决方案.
  • 我试过选择'重新加载更新'来暂时解决问题.我取消选择后再次显示相同的错误.

Screenshot2

在Microsoft边缘

  • 令人惊讶的是,升级后一切正常.

我的想法和期望

  • 由于应用程序在MS边缘工作正常,我怀疑服务工作者配置或我轮询更新的方式有什么问题
  • 我的期望是在/ ngsw/state中看到Drive状态为Normal

angular angular-service-worker angular7

34
推荐指数
1
解决办法
796
查看次数

Angular 4:在 NgModule 提供者数组中动态添加提供者

应用背景:我的应用是使用 ASP.net MVC(.net framework 4.6) 和几个 Angular 4 mini SPA 构建的

SPA 之一使用这种方法来引导组件。简而言之,这个 SPA 可以引导由一个 Angular 应用程序管理的多个组件。

问题只有当 html 视图中存在组件时,我才想在 providers 数组中添加一个提供者(如果这是正确的词,则动态添加)。希望大家帮帮忙?

示例我想在视图中加载/存在{ provide: APP_BASE_HREF, useValue: '/shoppingbasket/my' }时添加到 providers 数组AddProductToShoppingBasketComponent

代码

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ComponentFactoryResolver, ApplicationRef, Type } from '@angular/core';
import { HTTP_INTERCEPTORS } from "@angular/common/http";
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
//import { APP_BASE_HREF } from "@angular/common";

import { ToastrModule } from "ngx-toastr";
import …
Run Code Online (Sandbox Code Playgroud)

angular2-routing angular-cli angular

6
推荐指数
0
解决办法
779
查看次数

使用System.Linq.Dynamic在或包含查询

Background: I would like to use System.Linq.Dynamic library to post In/Contains query to MS SQL

Please note I am trying to use System.Linq.Dynamic in generic function so that I could apply customer filter to any class having CustomerId(integer) property. Also CustomerId property could be nullable

All SO posts redirects me to this solution. After implementing the same I keep getting this exception: "No generic method 'Contains' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No …

c# linq entity-framework-6

3
推荐指数
1
解决办法
697
查看次数

iOS 上的 Nativescript localhost http 调用失败

我在 Windows 上使用 Nativescript sidekick cloud build 在 iOS 上测试我的应用程序 - 我还连接了我的 iPhone。

根据这篇文章,我正在向 localhost 发送我的 http 请求,但他们一直因这个错误而失败。

http://localhost:52553/api/rewards/all 的Http 失败响应:0 未知错误
错误:无法连接到服务器。

这是我对奖励服务的实现

import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";

import { Observable, of } from 'rxjs';
import { SimpleReward } from "../models/simple-reward";
import { take, catchError } from "rxjs/operators";

@Injectable()
export class RewardsService {

    private baseUrl = "http://localhost:52553/api/rewards";

    constructor(private http: HttpClient) { }

    getAllRewards(): Observable<SimpleReward[]> {
        const url = `${this.baseUrl}/all`; …
Run Code Online (Sandbox Code Playgroud)

nativescript angular

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