不支持调用Angular2SocialLoginModule函数调用

编程入门 行业动态 更新时间:2024-10-27 13:34:28
本文介绍了不支持调用Angular2SocialLoginModule函数调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是angular js2的新手.目前,我正在使用Web应用程序,该应用程序将angular2用作前端.在此应用程序中,我已使用angular2-social-login进行身份验证.但是,当我运行npm start时,出现以下错误

I am new to angular js2. Currently I am working with a web application, which uses angular2 for front-end. In this application I have used angular2-social-login for authentication purpose. But when I run the npm start I got the below error

ERROR in Error遇到静态解析符号值的情况.调用函数"Angular2SocialLoginModule",不支持函数调用.考虑使用对导出函数的引用替换函数或lambda,在/var/www/html/ngtest/src/app/app.module.ts中解析符号AppModule,在/var/www/html/ngtest/中解析符号AppModule src/app/app.module.ts

ERROR in Error encountered resolving symbol values statically. Calling function 'Angular2SocialLoginModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in /var/www/html/ngtest/src/app/app.module.ts, resolving symbol AppModule in /var/www/html/ngtest/src/app/app.module.ts

当我在Google上搜索它时,有人说这是因为在项目中使用了角度cli.但是我卸载了angular cli,问题仍然存在. 有人知道如何解决这个问题吗?

When I google it, some one says that it is beacause of using angular cli in the project. But I uninstalled angular cli, still problem persists. Did any one know how to solve this issue?

我的app.module.ts代码在下面

My app.module.ts code is below

import { Angular2SocialLoginModule } from "angular2-social-login"; let providers = { "facebook": { "clientId": "xxxxxxxxxxxxx", "apiVersion": "v2.8" }, "linkedin": { "clientId": "xxxxxxxxxxx" }, "google": { "clientId": "xxxxxxxxxx" } }; @NgModule({ imports: [ Angular2SocialLoginModule.initWithProviders(providers), ], }) export class AppModule { }

我已经在headerponent.ts中调用了此模块,请参阅headerponent.ts文件

I have called this module in headerponent.ts, please see the headerponent.ts file

import { AuthService } from "angular2-social-login"; @Component({ selector: 'app-header', templateUrl: './headerponent.html', styleUrls: ['./headerponent.css'], providers: [Modal] }) export class HeaderComponent implements OnInit { constructor(public _auth: AuthService){ } signIn(provider){ this.sub = this._auth.login(provider).subscribe( (data) => { console.log(data); } )} logout(){ this._auth.logout().subscribe( (data)=>{ //return a boolean value. } )} }

以上是我的代码,请看一看.如果需要更多详细信息,请发表评论

The above is my code, Please have a look. If any more details needed please comment

推荐答案

更新

在angular2-social-login v.3.0.0中,您可以编写:

Update

In angular2-social-login v.3.0.0 you can write:

@NgModule({ ... imports: [ Angular2SocialLoginModule ] }) export class AppModule { constructor(){} } Angular2SocialLoginModule.loadProvidersScripts(providers);

旧版本

删除

imports: [ Angular2SocialLoginModule.initWithProviders(providers), ],

并尝试以下操作:

import { Angular2SocialLoginModule, AuthService } from "angular2-social-login"; @NgModule({ ... providers: [ AuthService ] }) export class AppModule { constructor() { Angular2SocialLoginModule.initWithProviders(providers); } }

更多推荐

不支持调用Angular2SocialLoginModule函数调用

本文发布于:2023-11-23 03:59:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620006.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不支持   函数   Angular2SocialLoginModule

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!