小编Wei*_*ies的帖子

PrimeNG Message 和 Toast 在组件中有效,但在服务中无效

我在使用 PrimeNG 框架的组件中有一个工作消息警报。

@成分

@Component({
    selector: 'app-client',
    templateUrl: './client.component.html',
    styleUrls: ['./client.component.css'],
    providers: [MessageService],
})
Run Code Online (Sandbox Code Playgroud)

构造函数

private msg: MessageService,
Run Code Online (Sandbox Code Playgroud)

成分法

this.msg.add({severity:'success', summary: 'Success Message', detail:'Order submitted'});
Run Code Online (Sandbox Code Playgroud)

但是一旦我转移到服务的方法并将“ClientService”包含在组件中

import { ClientService } from '../../../shared/services/client.service'
Run Code Online (Sandbox Code Playgroud)

在 client.service.ts 中导入消息

import { MessageService } from 'primeng/api';
...

@Injectable({
  providedIn: 'root'
})
Run Code Online (Sandbox Code Playgroud)

ClientService 中的方法

...
this.msg.add({severity:'success', summary:'Success', detail: msg});
...
Run Code Online (Sandbox Code Playgroud)

没有任何错误消息,也没有 toast 提示。我试图理解官方文档 https://www.primefaces.org/primeng/showcase/#/toast

使用 MessageService 显示消息,确保您的组件具有定义为提供者的可注入 MessageService,否则无法使用 Toast。

但我不知道如何“注入”消息服务。

示例项目在这里https://stackblitz.com/edit/d-toast

primeng angular

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

Firebase Cloud Function 设置超时 540 秒,但在 60 秒结束

我有我的云功能

\n
import * as functions from \'firebase-functions\';\nconst runtimeOpts = {\n    timeoutSeconds: 540,\n    memory: "1GB" as "1GB"\n\n}\n...\nexport const helloWorldAllowCORS = functions.runWith(runtimeOpts).https.onRequest(async (request, response) => {\n\n    response.set(\'Access-Control-Allow-Origin\', \'*\');\n    response.set(\'Access-Control-Allow-Credentials\', \'true\'); // vital\n\n    response.set(\'Keep-Alive\', \'timeout=5, max=1000\');\n\n    if (request.method === \'OPTIONS\') {\n        // Send response to OPTIONS requests\n        response.set(\'Access-Control-Allow-Methods\', \'GET\');\n        response.set(\'Access-Control-Allow-Headers\', \'Content-Type\');\n        response.set(\'Access-Control-Max-Age\', \'3600\');\n        response.status(204).send(\'\');\n    } else {\n        let run = async (ms: any) => {\n            await new Promise(resolve => setTimeout(resolve, ms));\n        }\n        await run(request.body.data.wait);\n\n        response.send({\n            data: {\n                status: true\n                , message: \'message …
Run Code Online (Sandbox Code Playgroud)

firebase google-cloud-functions angularfire2

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

自定义函数不适用于 ArrayFormula

我跟着帖子 https://developers.google.com/apps-script/guides/sheets/functions

function DOUBLE(input) {
    return input * 2;
}
Run Code Online (Sandbox Code Playgroud)

并将非常简单的 DOUBLE 函数复制到我的应用程序脚本中。

=double(A1)
Run Code Online (Sandbox Code Playgroud)

正在工作并在“A1”中加倍我的整数但是当我用值填充 A 列时,例如

A1 = 2
A2 = 3
A3 = 4
....
Run Code Online (Sandbox Code Playgroud)

在 B1 单元格中,我运行

=arrayformula(double(A1:A))
Run Code Online (Sandbox Code Playgroud)

它返回错误“结果不是数字”,#NUM!

我不确定出了什么问题。任何应用程序脚本大师都可以提供帮助吗?

谢谢

google-sheets google-apps-script

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

Firebase 云函数部署 - 内存属性无效

我的 firebase 云函数(TypeScript)通过参考官方文档https://firebase.google.com/docs/functions/manage-functions#set_timeout_and_memory_allocation包含了 runtimeOption

const runtimeOpts = {
  timeoutSeconds: 540,
  memory: "1GB"
}
..
export const GCPSpeech2TranscriptLRR = functions.runWith(runtimeOpts).https.onRequest((req, res) => {
Run Code Online (Sandbox Code Playgroud)

它返回部署错误

src/index.ts:145:58 - error TS2345: Argument of type '{ timeoutSeconds: number; memory: string; }' is not assignable to parameter of type 'RuntimeOptions'.
  Types of property 'memory' are incompatible.
    Type 'string' is not assignable to type '"128MB" | "256MB" | "512MB" | "1GB" | "2GB" | undefined'.

145 export const GCPSpeech2TranscriptLRR = functions.runWith(runtimeOpts).https.onRequest((req, res) => {
Run Code Online (Sandbox Code Playgroud)

我已经尝试了两种内存:“1GB”,内存:“1GB”,但我得到了同样的错误。如果我删除了“内存:...”行,它将正确部署。即使在 …

firebase google-cloud-functions

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