我正在寻找关于RXJS中Observable的简单英语解释.
它可以用于什么,以及任何有用的解释视频链接,教程,用例,示例,或任何真正的.
到目前为止,我在Udemy,Todd Motto,Youtube,Angular官方网站上找到的任何内容都没有找到我,我只是想要一个基本的解释,如果可能的话.
到目前为止,我所知道的是你可以用观察者订阅它们.它只是另一种变量吗?
提前致谢.
我正在构建一个具有公共 API 和内部 API 的应用程序。我想将这些文档发布到不同的路线。我认为这可以通过仅向文档(addTag)添加某些标签来完成,但经过进一步阅读和实验后,它并没有完成这项工作。
文档始终包含所有内容,所有模块的所有记录端点。
这可能吗?如果是这样,怎么办?
我不认为代码是必要的,但 FWIW:
const pubOptions = new DocumentBuilder()
.setTitle('Pub API Docs')
.setDescription('Blah blah API documentation')
.setVersion(p.version)
.addBearerAuth()
.addTag('public-app')
.build();
const document = SwaggerModule.createDocument(app, pubOptions);
SwaggerModule.setup('public-api', app, document);
const internalOptions = new DocumentBuilder()
.setTitle('Internal API Docs')
.setDescription('Blah blah API documentation')
.setVersion(p.version)
.addBearerAuth()
.addTag('internal')
.build();
const iDocument = SwaggerModule.createDocument(app, internalOptions);
SwaggerModule.setup('internal-api', app, iDocument);
Run Code Online (Sandbox Code Playgroud) 我有这个 MEAN Stack 应用程序,对于前端我使用的是 Angular 6,我创建了用户 root 和后端登录系统,我已经使用 Postman 对其进行了测试,它按预期工作。但是当我使用表单时,我总是在下面收到此错误:
我知道问题是将端口从 更改为4200,3000但还没有找到正确的解决方案。
这是我的服务:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';
@Injectable()
export class UserService {
constructor(
private _httpClient: HttpClient
) { }
public auth(user) {
return this._httpClient.post('users/login', user).pipe(map((resp: any) => resp.json()));
}
}
Run Code Online (Sandbox Code Playgroud)
这是我使用该服务的地方:
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { UserService } from '../../services/user.service';
@Component({
selector: …Run Code Online (Sandbox Code Playgroud) 所以,我几乎完成了在 NestJS 支持的应用程序中实现社交登录的尝试。但我有一些问题:
首先要事。我有AuthModule并且那里有提供者TwitterGuard:
const twitterOptions: IStrategyOptionWithRequest = {
consumerKey: process.env[ENV.SOCIAL.TWITTER_CONSUMER_KEY],
consumerSecret: process.env[ENV.SOCIAL.TWITTER_CONSUMER_SECRET],
callbackURL: process.env[ENV.SOCIAL.TWITTER_CALLBACK_URL],
passReqToCallback: true,
includeEmail: true,
skipExtendedUserProfile: false,
};
export class TwitterGuard extends PassportStrategy(Strategy, 'twitter') {
constructor() {
super(twitterOptions);
}
// Magical nest implementation, eq to passport.authenticate
validate(req: Request, accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) {
const user: SocialAuthUser = {
id: profile.id,
nick: profile.username,
name: profile.displayName,
};
if (profile.emails) {
user.email = profile.emails.shift().value; …Run Code Online (Sandbox Code Playgroud) 我的想法是让基本组件提供一些功能以及必要时添加matSuffix和<mat-hint>选项。组件HTML是:
<mat-form-field>
<textarea matInput matTextareaAutosize matAutosizeMinRows="1" matAutosizeMaxRows="3"
[placeholder]="placeholder" [formControl]="inputField"></textarea>
<ng-content></ng-content>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
但是当我在父HTML模板中使用它时
<my-component ...>
<button matSuffix ...><mat-icon>something</mat-icon></button>
<mat-hint>Press Ctrl+Enter to finish input</mat-hint>
</my-component>
Run Code Online (Sandbox Code Playgroud)
按钮和提示呈现在内部,mat-form-field而不是后缀或提示。
有人吗
编辑:Stackblitz
我想检查我的数组,如果我得到3,我想破坏我的forEach,如果不正确,则返回true或false。
但是当我在html-中按3时,我变得不确定
let errorSave: boolean = this.checkParams();
console.log("errorSave" , errorSave); // UNDEFINED
checkParams() {
let errorSave = this.params.forEach(element => {
if (element.origin === 3) {
return true;
}
});
return errorSave;
}
Run Code Online (Sandbox Code Playgroud) 我需要编辑库@ngx-translate/core 的管道,以了解哪些词没有被翻译并保存以将它们发送到单独的服务中
export class MyMissingTranslationHandler implements MissingTranslationHandler {
handle (params: MissingTranslationHandlerParams) {
if (params.translateService.currentLang === params.translateService.defaultLang) {
return 'not translate';
}
}
}
@NgModule ({
imports: [
BrowserModule,
HttpClientModule,
BrowserAnimationsModule,
RouterModule.forRoot (appRoutes),
SharedModule,
FuseMainModule,
TranslateModule.forRoot ({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
},
missingTranslationHandler: {provide: MissingTranslationHandler, useClass: MyMissingTranslationHandler}
}),Run Code Online (Sandbox Code Playgroud)
目前,这导致在没有翻译的单词中,将它们替换为“未翻译”一词,而我需要的是捕获无法翻译的单词。
我试图修改文件 translate.pipe.d.ts,但我不知道如何获得该值。真的非常感谢能帮助我的人
angular ×4
nestjs ×2
node.js ×2
typescript ×2
express ×1
javascript ×1
mongodb ×1
observable ×1
passport.js ×1
swagger ×1