this.userService.addUser(this.user).subscribe(\n (data)=>{\n //success\n console.log(data);\n this._snack.open('Registered Successfully', 'OK', {\n duration: 2000,\n verticalPosition: 'top',\n horizontalPosition: 'center',\n panelClass: ['green-snackbar', 'login-snackbar'],\n });\n },\n (error)=>{\n //error\n console.log(error);\n this._snack.open('Something went Wrong', 'OK', {\n duration: 2000,\n verticalPosition: 'top',\n horizontalPosition: 'center',\n panelClass: ['red-snackbar','login-snackbar'],\n });\n }\n);\nRun Code Online (Sandbox Code Playgroud)\n我不知道到底发生了什么,但订阅显示已弃用,以下是消息
\n(method) Observable<Object>.subscribe(next?: ((value: Object) => void) | null | undefined, error?: ((error: any) => void) | null | undefined, complete?: (() => void) | null | undefined): Subscription (+2 overloads)\n@deprecated \xe2\x80\x94 Instead of passing separate callback arguments, use an observer …Run Code Online (Sandbox Code Playgroud) rxjs7 ×1