我对angular不熟悉,我一直在尝试按照本教程将社交媒体登录集成到我的项目中: https://www.npmjs.com/package/angularx-social-login 我已经安装了angularx-social-login库并遵循以下依赖关系 -tslint
-@ angular /代码
-@ angular / common
-rxjs
现在我有“错误:必须从注入上下文中调用Inject()”。
我已经尝试了angular.json文件中的prepareSymlinks,但是没有用。
屏幕截图:
function myFunction() {
var old_url ="http://hurlx1.com";
var new_url ="http://urlxa.com";
var files = DriveApp.getFolderById("my folder id").getFilesByType(MimeType.GOOGLE_DOCS);
while (files.hasNext()) {
var file = files.next();
var doc = DocumentApp.openById(file.getId());
var body = doc.getBody();
// The following script is used for the situation that the text and hyperlink are the same with `old_url`.
var found = body.findText(old_url);
while (found) {
var link_element = found.getElement().asText();
var start = found.getStartOffset();
var end = found.getEndOffsetInclusive();
var correct_link = link_element.getText().slice(start, end);
link_element.setLinkUrl(start, end, new_url).replaceText(old_url, new_url);
found = body.findText(old_url, found);
}
// The following script is used for the situation that although the hyperlink is `old_url`, the text is different from `old_url`.
var text = body.editAsText();
for (var i = 0; i < text.getText().length; i++) {
if (text.getLinkUrl(i) == old_url) {
text.setLinkUrl(i, i + 1, new_url);
}
}
}
}
我的app.module.ts代码:
Error: Inject() must be called from an injection context console screen
.ts文件包含方法:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { DaneComponent } from './dane/dane.component';
import { SocialLoginModule, AuthServiceConfig } from "angularx-social-login";
import { GoogleLoginProvider, FacebookLoginProvider } from "angularx-social-login";
let config = new AuthServiceConfig([
{
id: GoogleLoginProvider.PROVIDER_ID,
provider: new GoogleLoginProvider("I'm aware that I need to put app ID here")
},
{
id: FacebookLoginProvider.PROVIDER_ID,
provider: new FacebookLoginProvider("I'm aware that I need to put app ID here")
}
]);
export function provideConfig() {
return config;
}
@NgModule({
declarations: [
AppComponent,
DaneComponent
],
imports: [
BrowserModule,
AppRoutingModule,
SocialLoginModule
],
providers: [
{
provide: AuthServiceConfig,
useFactory: provideConfig
}
],
bootstrap: [AppComponent]
})
export class AppModule { }
答案 0 :(得分:0)
发现了问题。
我在错误的目录中而非我的项目中安装了angularx-social-module。