我想在我的Angular 2項目中實現auth0,並且我不想使用鎖定小部件,而是自定義我自己的登錄窗體和按鈕社交登錄。所以我想自己使用auth0庫。我希望它被捆綁,所以不要在index.html中導入它。Auth0-js與Angular 2(RC5),Webpack和CLI
我已經使用CLI搭建了我的項目(1.0.0-beta.11-webpack.2),並安裝了帶有NPM的auth0-js。我可以在我的node_modules中找到'auth0-js'文件夾,現在我只需要以某種方式將它連接到我的應用程序。
// login.component
import { Component } from '@angular/core';
import * as Auth0 from "auth0-js";
@Component({
selector: 'app-login',
templateUrl: 'login.component.html',
styleUrls: ['login.component.css']
})
export class LoginComponent implements OnInit {
auth0: any;
constructor() {
this.auth0 = new Auth0({
domain: 'myDomain',
clientID: 'myClientId',
callbackURL: '{http://localhost:4000/}', // in dev-mode
callbackOnLocationHash: true
});
}
loginWithGoogle(connection) {
this.auth0.login({
connection: 'google-oauth2'
});
}
}
但我從的WebPack得到這個控制檯消息:[默認] ... /node_modules/@types/auth0-js/index.d
錯誤。 ts'不是一個模塊。
看來應用程序正在工作,雖然類型不起作用。我已經安裝了npm i @types/auth0-js --save
,並按預期的方式將類型安裝到我的節點模塊中。
似乎這是類型錯誤的類型,但什麼?這是我可以解決的一個問題,還是需要等到有人更新模塊才能解決問題?
謝謝!
這並沒有這樣的伎倆很遺憾。但我似乎錯了......該應用程序完全符合我的意見,這只是缺少的類型。 – mottosson