小编Adi*_*ari的帖子

Angular从第5版降级到第4版

我想,当我运行此命令的版本降级到角CLI 4创建角4项目,而不是5角我CLI版本1.5.0

npm install -g angular-cli@1.4.9
Run Code Online (Sandbox Code Playgroud)

我收到了错误

npm ERR! code ETARGET
npm ERR! notarget No matching version found for angular-cli@1.4.9
Run Code Online (Sandbox Code Playgroud)

angular-cli angular

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

firebase 导入服务抛出错误

我正在使用 firebase 函数,我想使用服务帐户密钥 json 将 App 初始化为凭据,但出现错误

'{ "type": string; 类型的参数 “project_id”:字符串;“private_key_id”:字符串;“private_key”:字符串;“client_...”不能分配给“string | ServiceAccount”类型的参数。类型“{“type”:string;“project_id”:string;“private_key_id”:string;“private_key”:string;“client_.. .' 与类型 'ServiceAccount' 没有共同的属性。

我的 index.ts 文件

 import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin'
import {serviceAccount} from './serviceAccount'

console.log(functions.config())
admin.initializeApp({
    credential: admin.credential.cert(serviceAccount),
    databaseURL:functions.config().firebase
});

export const firestore = admin.firestore();
export const firebase = admin.database();
Run Code Online (Sandbox Code Playgroud)

serviceAccount.ts

export const serviceAccount = {

    "type": "service_account",
    "project_id": "lxxxxxx",
    "private_key_id": "xxxxxx",
    "private_key": "-----BEGIN PRIVATE KEY-----xxxxxxx---END PRIVATE KEY-----\n",
    "client_email": "firebase-axxxxx-9b58b.iaxxxceaccount.com",
    "client_id": "xxxxx",
    "auth_uri": "https://accounts.google.com/o/xxxxx",
    "token_uri": "https://accounts.google.com/o/oxxxxn",
    "auth_provider_x509_cert_url": …
Run Code Online (Sandbox Code Playgroud)

node.js firebase google-cloud-functions

10
推荐指数
2
解决办法
2121
查看次数

带有await的firebase on('value')不能按预期工作

我正在寻找构建函数,等待所有值都打开('value'),然后转到下一行,换句话说是异步函数.

 let upcomingGamesList = await firebase.database().ref('UpcomingGames').on('value', snapshot => {
        upcomingGamesList = snapshot.val()
        console.log('upcoming t1',upcomingGamesList)
        return upcomingGamesList
    })
    console.log('upcoming t2',upcomingGamesList)
    let upcomingPreferences = upcomingGamesList.map(async(game) => {
        console.log(game)
        let GameId = game.GameId
        await firebase.database().ref(`GameNotificationPreferances/${GameId}`).orderByKey().equalTo(UserStore.user.uid).once('value', snapshot => {
            if (snapshot.val() != null || snapshot.val() != undefined) {
                conosle.log(snapshot.val())
            } else {
                console.log('not value')
            }
        })
        console.log(game)
    })
Run Code Online (Sandbox Code Playgroud)

发生了什么是即将到来的t2

        console.log('upcoming t2',upcomingGamesList)
Run Code Online (Sandbox Code Playgroud)

在即将到来的t1之前打印

    console.log('upcoming t2',upcomingGamesList)
Run Code Online (Sandbox Code Playgroud)

但是我在这个函数中使用了await

  let upcomingGamesList = await firebase.database().ref('UpcomingGames').on('value', snapshot => {
        upcomingGamesList = snapshot.val()
        console.log('upcoming t2',upcomingGamesList)
        return upcomingGamesList
    })
Run Code Online (Sandbox Code Playgroud)

它应该等到它完成然后转到下一行

我想等到函数完成后再使用我所做的更改获取updatedList

 let …
Run Code Online (Sandbox Code Playgroud)

javascript firebase firebase-realtime-database

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

离子3发布应用程序作为PWA(Progressive Web App)

我想发布我的应用程序作为PWA,所以我做的是

将此脚本插入index.html

<!--script>
    if ('serviceWorker' in navigator) {
      navigator.serviceWorker.register('service-worker.js')
        .then(() => console.log('service worker installed'))
        .catch(err => console.log('Error', err));
    }
</script-->
Run Code Online (Sandbox Code Playgroud)

然后安装

npm run ionic:build --prod 
Run Code Online (Sandbox Code Playgroud)

看起来它部署它但我的问题是:

  1. 我需要将哪些文件上传到主机以将应用程序发布为PWA?
  2. 为什么当我在应用程序中更改某些内容并运行离子服务时没有任何更改,它只在WWW文件夹的index.html中更改?为什么?(因为现在是PWA?)

  3. 当我打开www文件夹并运行打开index.html时,我按下打开警告对话框的按钮它不会打开它.为什么?

  4. 当我运行命令?只是在发展的最后?

ionic-framework ionic2 progressive-web-apps ionic3

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

模块'AppModule'声明的意外模块'MdAutocompleteModule'.请添加@ Pipe/@ Directive/@ Component注释

安装角度材料后,我在角度4项目中出现此错误

模块'AppModule'声明的意外模块'MdAutocompleteModule'.请添加@ Pipe/@ Directive/@ Component注释.

这是我的app.module.ts

   import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';


import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { environment } from './../environments/environment';

import { AngularFireModule } from 'angularfire2';
// New imports to update based on AngularFire2 version 4
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { AngularFireAuthModule } from 'angularfire2/auth';

// import material
import …
Run Code Online (Sandbox Code Playgroud)

material-design angular-material angular

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

角度2:阻止用户在模态对话框外单击

我想阻止用户在模态对话框外单击,他只能按下按钮退出对话框.我怎样才能做到这一点?

dialog.component.ts

ngOnInit() {

const dialogRef = this.dialog.open(DialogResultComponent);
dialogRef.afterClosed().subscribe(result => {
  console.log(result);
});
Run Code Online (Sandbox Code Playgroud)

}

对话框的result.component.ts

    import { Component, OnInit } from '@angular/core';
import { MdDialog, MdDialogRef } from '@angular/material';
import { FormGroup,FormControl,Validators,FormBuilder,  } from '@angular/forms';



@Component({
  selector: 'app-dialog-result',
  templateUrl: './dialog-result.component.html',
})

export class DialogResultComponent {


  form: FormGroup;
  name = new FormControl('',Validators.required);
  width = new FormControl('',Validators.required);
  height = new FormControl('',Validators.required);
  constructor(public dialogRef: MdDialogRef<DialogResultComponent>,private fb: FormBuilder) {

  }

  ngOnInit() {
  this.form = this.fb.group({
      'name' :this.name,
      'width':   this.width,
      'height':  this.height,
    });
}

  saveData(){ …
Run Code Online (Sandbox Code Playgroud)

css modal-dialog angular-material2 angular

8
推荐指数
2
解决办法
9942
查看次数

找不到模块'webpack-cli'

我想让es6进入我的项目,所以我在本教程中使用本教程 ,当我尝试在cmd中编写'webpack'时出现错误

    Done in 8.99s.
{ Error: Cannot find module 'webpack-cli'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at runCommand.then.result (C:\Users\adirz\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:62:14)
    at process._tickCallback (internal/process/next_tick.js:109:7) code: 'MODULE_NOT_FOUND' }
Run Code Online (Sandbox Code Playgroud)

的package.json

   {
  "name": "functions",
  "scripts": {
    "build": "tsc",
    "serve": "npm run build && firebase serve --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "~5.12.0",
    "firebase-functions": "^1.0.1"
  },
  "devDependencies": …
Run Code Online (Sandbox Code Playgroud)

firebase ecmascript-6 webpack

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

reCAPTCHA容器未找到或已包含内部元素

当我尝试进行手机验证时,我在角度4中收到错误.

我在控制台中遇到此错误

reCAPTCHA容器未找到或已包含内部元素!

我没有在网上看到reCAPTCHA容器,也无法按下它.

登录-page.ts

 import { Component, OnInit } from '@angular/core';
// tslint:disable-next-line:quotemark
import { Router } from "@angular/router";
// tslint:disable-next-line:quotemark
import { AuthService } from "../../core/auth.service";

import { ReactiveFormsModule } from '@angular/forms';
import * as firebase from 'firebase';


export class PhoneNumber {

  country: string;

  area: string;

  prefix: string;

  line: string;

  // format phone numbers as E.164

  get e164() {

    const num = this.country + this.area + this.prefix + this.line

    return `+${num}`

  }


}

@Component({
  // tslint:disable-next-line:component-selector
  selector: 'user-login', …
Run Code Online (Sandbox Code Playgroud)

authentication angularfire2 angular

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

firestore 错误:参数“documentPath”必须指向文档

我使用 firebase/firestore 构建 react native 应用程序,但出现错误

Error: Argument "documentPath" must point to a document.
Run Code Online (Sandbox Code Playgroud)

当我写这行时

    var userStatusFirestoreRef = firebase.firestore().doc('/status/' + uid);
Run Code Online (Sandbox Code Playgroud)

所有代码

    firebase.auth().signInAnonymouslyAndRetrieveData().then((user) => {
    var uid = firebase.auth().currentUser.uid;

    var userStatusFirestoreRef = firebase.firestore().doc('/status/' + uid);
});
Run Code Online (Sandbox Code Playgroud)

firebase react-native google-cloud-firestore

7
推荐指数
2
解决办法
6423
查看次数

与Firebase FCM一起使用本机

我正在尝试通过此文档使用React Native和Firebase实现推送通知.

我在本教程中设置了我需要的设置.

   import React, { Component } from 'react'
import { View } from 'react-native'
import { Input, Text, Button } from '../Components'
import type { RemoteMessage } from 'react-native-firebase'
import firebase from 'react-native-firebase'
import type { Notification, NotificationOpen } from 'react-native-firebase';

export default class TestComponent extends Component {

  async componentDidMount() {
    await this.SetUpAuth();
    await this.SetUpMessaging();
    this.notificationOpenedListener = firebase.notifications().onNotificationOpened((notificationOpen: NotificationOpen) => {
      // Get the action triggered by the notification being opened
      const action = notificationOpen.action;
      // …
Run Code Online (Sandbox Code Playgroud)

javascript firebase react-native firebase-cloud-messaging

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