首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使角度-社会--使用角度

如何使角度-社会--使用角度
EN

Stack Overflow用户
提问于 2018-01-26 14:44:09
回答 1查看 887关注 0票数 0

我是angular2-social-auth,在带有角5的项目中,但是它给了我一个错误,这是代码:

Module.ts

代码语言:javascript
复制
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';


import { AppComponent } from './app.component';
import { Angular2SocialLoginModule } from "angular2-social-auth";

let providers = {
  /* "google": {
  "clientId": "GOOGLE_CLIENT_ID"
},
"linkedin": {
  "clientId": "LINKEDIN_CLIENT_ID"
 },*/
"facebook": {
   "clientId": "MyGeneratedCode",
   "apiVersion": "v2.11" //like v2.4
 }

};

代码语言:javascript
复制
@NgModule({
 declarations: [
  AppComponent
   ],
imports: [
 BrowserModule,
  Angular2SocialLoginModule
],
 providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Angular2SocialLoginModule.loadProvidersScripts(providers);

component.ts:

代码语言:javascript
复制
import { Component, OnDestroy } from '@angular/core';
import { AuthService } from "angular2-social-auth";

@Component({
 selector: 'app-root',
 templateUrl: './app.component.html',
 styleUrls: ['./app.component.css']
 })
 export class AppComponent  implements OnDestroy {

 title = 'app';

  constructor(public _auth: AuthService){ }

 signIn(provider){
 this._auth.login(provider).subscribe(
   (data) => {
               console.log(data);
               //user data
               //first_name, last_name, image, uid, provider, email, token     (returns  accessToken for Facebook and Google no token for linkedIn)
             }
 )

}

代码语言:javascript
复制
 logout(){
   this._auth.logout().subscribe(
   (data)=>{
     //return a boolean value.
    }
  )
 }

}

html:

代码语言:javascript
复制
<h1>
 Sign in
</h1>

<button (click)="socialSignIn('facebook')">Sign in with Facebook</button>
<button (click)="socialSignIn('google')">Signin in with Google</button>   

我做了文档告诉我的事情,有谁能帮忙吗?当我循环facebook按钮时,它给了我一个错误:

View_AppComponent_0/<@ng:///AppModule/AppComponent.ngfactory.js:14:19:_co.socialSignIn不是函数堆栈跟踪:TypeError handleEvent@webpack-internal:///../../../core/esm5/core.js:13745:115

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-26 14:47:57

您尝试在html中调用一个名为"socialSignIn“的函数,但是我在代码中没有看到这个函数。因此,错误信息是明确的:socialSignIn is not a function

尝试调用signIn('facebook')代替

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48463646

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档