小编Aak*_*kur的帖子

TypeError:您提供了一个无效的对象,其中包含一个流.您可以提供Observable,Promise,Array或Iterable

我试图map从服务电话,但得到一个错误.看看订阅没有在角度2中定义?它说,为了订阅我们需要从运营商内部返回.我也有回复陈述.

这是我的代码:

checkLogin(): Observable<boolean> {
    return this.service.getData()
        .map(
            response => {
                this.data = response;                            
                this.checkservice = true;
                return true;
            },
            error => {
                // debugger;
                this.router.navigate(['newpage']);
                console.log(error);
                return false;
            }
        )
        .catch(e => {
            return e;
        });
}
Run Code Online (Sandbox Code Playgroud)

错误日志:

TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable
Run Code Online (Sandbox Code Playgroud)

observable rxjs typescript angular

49
推荐指数
7
解决办法
11万
查看次数

客户无权访问Firebase中的所需数据

我有一个调用addCheckin()方法的页面,它位于控制器内部.在控制器中,我试图创建一个如下引用:

var ref = firebase.database().ref("users/" + $scope.whichuser + "/meetings/" +$scope.whichmeeting + "/checkins");
Run Code Online (Sandbox Code Playgroud)

$scope.whichuser并且$scope.whichmeeting$routeParams,我从其他途径传递.这是我的签到控制器 -

myApp.controller("CheckinsController",
    ['$scope','$rootScope','$firebaseArray','$routeParams','$firebaseObject',
    function($scope,$rootScope,$firebaseArray,$routeParams,$firebaseObject){

        $scope.whichuser = $routeParams.uid;
        $scope.whichmeeting = $routeParams.mid;

        var ref = firebase.database().ref("users/" + $scope.whichuser + "/meetings/" +$scope.whichmeeting + "/checkins");

        $scope.addCheckin = function(){
            var checkinInfo = $firebaseArray(ref);
            var data={
                firstname:$scope.firstname,
                lastname:$scope.lastname,
                email:$scope.email,
                date:firebase.database.ServerValue.TIMESTAMP
            }

            checkinInfo.$add(data);
        }

}]);/*controller*/
Run Code Online (Sandbox Code Playgroud)

我在这里遇到两个错误 -

错误1:

Error: permission_denied at /users/Vp2P1MqKm7ckXqV2Uy3OzTnn6bB3/meetings: Client doesn't have permission to access the desired data.

错误2:

Error: permission_denied at /users/Vp2P1MqKm7ckXqV2Uy3OzTnn6bB3/meetings/-KT5tqMYKXsFssmcRLm6/checkins: Client …

angularjs firebase angularfire firebase-authentication firebase-realtime-database

20
推荐指数
4
解决办法
2万
查看次数

firebase中的Google身份验证显示空白屏幕Progressive Web App

我正在创建我的第一个Progressive Web应用程序,该应用程序使用firebase存储数据.我也Gmail用作所有使用该应用程序的用户的入口点.但是我坚持实施登录.以下是我登录的代码:

HTML:

<button md-raised-button color="warn" (click)="logInGoogle()"><md-icon>group</md-icon>Sign in with google to enjoy the app</button> 
Run Code Online (Sandbox Code Playgroud)

TS:

logInGoogle(){
    this.authService.loginWithGoogle().then( user => {
      console.log("User is logged in");
      //this.router.navigate(['/addweather']);
    })
    .catch( err => {
      console.log('some error occured');
    })
  }
Run Code Online (Sandbox Code Playgroud)

这是服务:

loginWithGoogle() {
    return this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
  }
Run Code Online (Sandbox Code Playgroud)

还要auth在我的app.component.ts构造函数中检查状态:

this.authService.afAuth.authState.subscribe(
      (auth) => {
        if(auth === null){
          console.log("Not Logged in.");
          this.router.navigate(['login']);
          this.isLoggedIn = false;
        }
        else {
          console.log("Successfully Logged in.");
          this.isLoggedIn = true;
          this.router.navigate(['']);
        }
      }
    )
Run Code Online (Sandbox Code Playgroud)

现在,应用程序显示了一些行为:

  1. 此登录功能在浏览器上工作正常,如果我单击登录按钮,它会打开一个新窗口,授权我并返回打开该应用程序的同一选项卡.

  2. 当我将应用程序添加到主屏幕并尝试再次登录时,它会提示我以下选项:

在此输入图像描述

一旦我点击chrome,它就会授权我并将我重定向到应用程序,但是应用程序现在显示一个空白屏幕,oAuth屏幕进入无限处理状态. …

firebase firebase-authentication progressive-web-apps angular

18
推荐指数
2
解决办法
1776
查看次数

部署后找不到node_modules

这个标题可能有点误导,但请耐心等待一段时间.

Angular2在2015年的visual studio上制作了一个简单的应用程序,现在我已经有了published it on Azure.

在开发环境中使用node_modules是完美的,但在部署之后显示错误,说无法找到node_modules.

以下是我在index.html的开发环境中引用的方法-

<!-- Polyfill(s) for older browsers -->
    <script src="/node_modules/core-js/client/shim.min.js"></script>
    <script src="/node_modules/zone.js/dist/zone.js"></script>
    <script src="/node_modules/reflect-metadata/Reflect.js"></script>
    <script src="/node_modules/systemjs/dist/system.src.js"></script>
    <script src="/systemjs.config.js"></script>
Run Code Online (Sandbox Code Playgroud)

它也在system.config.js中引用-

/**
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(function(global) {

// map tells the System loader where to look for things
var map = {
'app':                        '/app', // 'dist',

'@angular':                   '/node_modules/@angular',
'angular2-in-memory-web-api': '/node_modules/angular2-in-memory-web-api',
'rxjs':                       '/node_modules/rxjs'
};

// packages …
Run Code Online (Sandbox Code Playgroud)

deployment azure node-modules typescript angular

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

默认单选按钮选择值角度材料2

我正在使用角度材料2单选按钮,遵循以下文档:https://material.angular.io/components/component/radio.

我面临的问题是让单选按钮的默认选择值为No.如果您在plunker中看到:https://plnkr.co/edit/jdRxVLdSfFqR4XOdpyUN p = preview,您会发现没有选择任何选项.我希望默认值是No页面加载时.

angular-material2 angular

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

TypeError:r.getClientRects不是函数

我试图在此链接后在KendoUI网格中创建一个自定义工具栏:http://demos.telerik.com/kendo-ui/grid/toolbar-template 但遇到错误.

这就是我在我的代码中尝试做的事情:

<div id="example">
    <script type="text/x-kendo-template" id="template">
        <div class="toolbar">
            <label class="category-label" for="category">Show products by category:</label>
            <input type="search" id="category" style="width: 150px" />
        </div>
    </script>
    <div id="grid"></div>
    <script>
        $(document).ready(function () {
            var grid = $("#grid").kendoGrid({
                dataSource: {

                    transport: {
                        read: {
                            url: 'http://localhost:52738/Default1/KendoDataAjaxHandle',
                            type: "post",
                            dataType: "json"
                        }
                    },
                    schema: {
                        data: "Data",
                        total: function (response) {
                            return $(response.Data).length;
                        }
                    },
                    pageSize: 10
                },
                toolbar: kendo.template($("#template").html()),
                groupable: true,
                sortable: true,
                pageable: {
                    refresh: true,
                    pageSizes: true,
                    buttonCount: 5
                }, …
Run Code Online (Sandbox Code Playgroud)

html javascript toolbar kendo-ui kendo-ui-grid

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

布尔玛下拉不起作用

Bulma下拉列表似乎没有在点击时切换.以下是文档中的代码片段:https://bulma.io/documentation/components/dropdown/

<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.0/css/bulma.min.css" rel="stylesheet"/>


<div class="dropdown is-active">
  <div class="dropdown-trigger">
    <button class="button" aria-haspopup="true" aria-controls="dropdown-menu">
      <span>Dropdown button</span>
      <span class="icon is-small">
        <i class="fa fa-angle-down" aria-hidden="true"></i>
      </span>
    </button>
  </div>
  <div class="dropdown-menu" id="dropdown-menu" role="menu">
    <div class="dropdown-content">
      <a href="#" class="dropdown-item">
        Dropdown item
      </a>
      <a class="dropdown-item">
        Other dropdown item
      </a>
      <a href="#" class="dropdown-item is-active">
        Active dropdown item
      </a>
      <a href="#" class="dropdown-item">
        Other dropdown item
      </a>
      <hr class="dropdown-divider">
      <a href="#" class="dropdown-item">
        With a divider
      </a>
    </div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

javascript css bulma

6
推荐指数
2
解决办法
8445
查看次数

找不到ionic.config.json文件.你在离子项目吗?

我是Ionic的新手,并试图运行ionic serve来测试我的应用程序,但我不断收到此错误:

Couldn't find ionic.config.json file. Are you in an Ionic project?
Run Code Online (Sandbox Code Playgroud)

在运行时ionic info,我得到以下内容:

 $ ionic info
******************************************************
 Dependency warning - for the CLI to run correctly,
 it is highly recommended to install/upgrade the following:

 Please update your Cordova CLI to version  >=4.2.0 `npm install -g cordova`

******************************************************

Your system information:

Cordova CLI: undefined
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.1.7
OS: Windows 7
Node Version: v4.4.5
Run Code Online (Sandbox Code Playgroud)

尝试找不到ionic.config.json文件,但无法解决问题.

我在创建应用程序时也得到了这个跟踪ionic start myApp …

node.js cordova ionic-framework

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

组件是两个模块声明的一部分:AppRoutingModule和AppModule

我试图通过在自己的打字稿文件中定义路由模块来将其与其他模块分开.但是我得到了上面的错误:Component是两个模块声明的一部分:AppRoutingModule和AppModule

共享以下两个模块:

AppRoutingModule

import { NgModule } from '@angular/core'
import { RouterModule, Routes } from '@angular/router'
import { AdminHomeComponent } from './nav/adminhome.component'
import { UserHomeComponent } from './nav/userhome.component'
import { ContactComponent } from './nav/contact.component'
import { LandingComponent } from './nav/mainhome.component'
import { LoginFormComponent } from './nav/login.component'


const appRoutes: Routes = [
    { path: 'login', component: LoginFormComponent },
    { path: 'adminHome', component: AdminHomeComponent },
    { path: 'userHome', component: UserHomeComponent },
    { path: 'contact', component: ContactComponent },
    { path: '', component: …
Run Code Online (Sandbox Code Playgroud)

routing components module angular

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

返回布尔值而不是订阅canActivate

我有一个受canActivate防护保护的组件.checkLogin函数中的Authguard 从一个observable订阅,但我不知道如何从它返回一个布尔值到canActivate.

guard.service.ts

canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
    let url: string = state.url;

    return this.checkLogin(url);
  }

    public checkService:boolean;
  checkLogin(url: string):boolean {

         return this.loadAppSettings().subscribe(res=>{
              console.log(this.checkservice);
              if (this.checkservice == true) 
              {
                   return true; 
            }
            else{
                this.router.navigate(['/error-user']);
                return false;
            }
            });
      }//checkLogin throws error as type subscription is not assignable to type boolean
Run Code Online (Sandbox Code Playgroud)

所以我想要的是如果它this.checkService是真的它应该返回true并且用户应该能够登陆被保护的路线但是如果它是假的,他应该被导航到error-user.

Angular2 - 返回布尔值,订阅canActivate这个问题与我的类似,但无法解决我的问题.

有人可以在这帮忙.

rxjs angular2-routing angular

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

Heroku推被拒绝

我在将我的主分支推送到heroku时遇到问题.我使用以下命令:

git push heroku master
Run Code Online (Sandbox Code Playgroud)

我遇到的错误 -

Counting objects: 114, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (112/112), done.
Writing objects: 100% (114/114), 335.40 KiB | 0 bytes/s, done.
Total 114 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Failed to detect set buildpack https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/php.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:

remote: !       Push rejected to skyconfapp.
remote:
To https://git.heroku.com/skyconfapp.git …
Run Code Online (Sandbox Code Playgroud)

git heroku

4
推荐指数
2
解决办法
9336
查看次数

具有动态数据的垂直表

似乎与AngularJS“Vertical”ng-repeat具有相同的要求,但解决方案不适用于 *ngFor

我正在object array尝试将其绑定到 HTML 表。它的格式如下:

[
 {
   "Animal":"Dog",
   "Country":"France",
   "Food":"Tofu",
   "Car":"Nano",
   "Language":"TypeScript"
 }
]
Run Code Online (Sandbox Code Playgroud)

现在可以简单地以默认的 HTML 水平表格方式进行格式化,如下所示:

<table>
  <tr>
    <th>Animal</th>
    <th>Country</th>
    <th>Food</th>
    <th>Car</th>
    <th>Language</th>
  </tr>
  <tr *ngFor="let data of datas">
    <td>{{data.Animal}}</td>
    <td>{{data.Country}}</td>
    <td>{{data.Food}}</td>
    <td>{{data.Car}}</td>
    <td>{{data.Language}}</td>
  </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

这将创建如下表(请忽略表中的数据;它只是为了提供一个想法。):

[1]:https://i.stack.imgur.com/VG

但是我如何使用动态数据创建这样的结构(类似于垂直表): 在此输入图像描述

html css angular

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

mat-tab-group 不显示所选默认选项卡的样式

我有三个标签:label1,label2label3。每一个内部都有另一组选项卡。现在默认label1显示所选样式及其tab1内部。现在,一旦我点击另一个标签,就像label 2另一组标签加载,但没有一个标签显示突出显示。也一样label3。我必须明确单击选项卡才能查看样式。

请找到该问题的链接:https : //stackblitz.com/edit/angular-tyjslw?file=app/tabs-template-label-example.html

angular-material2 angular

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