我有一个全局加载器,实现如下:
CoreModule:
router.events.pipe(
filter(x => x instanceof NavigationStart)
).subscribe(() => loaderService.show());
router.events.pipe(
filter(x => x instanceof NavigationEnd || x instanceof NavigationCancel || x instanceof NavigationError)
).subscribe(() => loaderService.hide());
Run Code Online (Sandbox Code Playgroud)
LoaderService:
@Injectable({
providedIn: 'root'
})
export class LoaderService {
overlayRef: OverlayRef;
componentFactory: ComponentFactory<LoaderComponent>;
componentPortal: ComponentPortal<LoaderComponent>;
componentRef: ComponentRef<LoaderComponent>;
constructor(
private overlay: Overlay,
private componentFactoryResolver: ComponentFactoryResolver
) {
this.overlayRef = this.overlay.create(
{
hasBackdrop: true,
positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically()
}
);
this.componentFactory = this.componentFactoryResolver.resolveComponentFactory(LoaderComponent);
this.componentPortal = new ComponentPortal(this.componentFactory.componentType);
}
show(message?: string) {
this.componentRef = this.overlayRef.attach<LoaderComponent>(this.componentPortal);
this.componentRef.instance.message = …Run Code Online (Sandbox Code Playgroud) 我正试图在我的角度5.2应用程序中重新加载我的导航而没有任何成功.如果参数不变,角度路由器将忽略我的导航.
我如何导航:
this.router.navigate(['/search', buildParamsFromSearchCriteria(criteria)]);
Run Code Online (Sandbox Code Playgroud)
导航到:
/search;pageSize=20;page=1;orderBy=price;sortDirection=ASCENDING
Run Code Online (Sandbox Code Playgroud)
我的模块配置:
imports: [RouterModule.forRoot(appRoutes, { preloadingStrategy: PreloadAllModules, enableTracing: false, onSameUrlNavigation: 'reload' })],
Run Code Online (Sandbox Code Playgroud) 我想使用联合类型的键作为打字稿中对象的键。
type EnumType = 'a1' | 'a2'
const object:{[key in EnumType]: string}= {
a1: 'test'
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我什至必须添加 a2 作为对象中的键。有没有办法让它成为可选的?
我已成功在web.xml(java-webcontainer)中设置FORM-authentication.
在使用FORM-Authentication时,我没有找到在我的客户端的restful-uri的get-request中发送用户名/密码的方法.所以我必须只为restful-uri使用BASIC-Authentication.
所以我有这个问题:
如何设置基于表单的身份验证和基本身份验证?只应为restful-uri启用基本身份验证.
{code:200,id:4,msg:"success",user:"Sourav"}
我有一个问题,我想将本地存储中的ID和用户存储为加密格式.如何使用Angular 6进行操作?
I have a SSR Angular app which I am trying to transform into a PWA. I want it to be server-side rendered for SEO and for the "fast first rendering" that it provides.
The PWA mode works fine when combined with SSR, but once the app is loaded, when we refresh it, the client index HTML file is loaded instead of the server-side rendered page.
I have dug into the code of ngsw-worker.js and I saw this:
// Next, check …Run Code Online (Sandbox Code Playgroud) javascript progressive-web-apps angular-universal angular angular-service-worker
我们有以下配置:
testing.parentdomain.com
当您访问该域并创建一个购物篮时,我们会创建一个存储该购物篮价值的 cookie。cookie 域设置为.testing.parentdomain.com,它是 Httponly 并且有一个路径/
我们有一个想要访问 cookie 的子域。subdomain.testing.parentdomain.com
此子域调用父域上的端点,例如:testing.parentdomain.com/basketData。此调用是返回 JSON 的 GET 请求。
问题
问题是子域在发出请求时似乎没有发送 cookie 值,因此我们没有得到预期的响应。
尝试
查看其他问题,我们尝试过 CORS 和凭证更改。
作为附加说明,我们将以下 JS 与 webpack/babel 捆绑在一起。
我们的请求来自 AJAX,如下所示:
$.ajax({
url: url,
type: 'GET',
xhrFields: {
withCredentials: true
},
crossDomain: true
})
Run Code Online (Sandbox Code Playgroud)
服务器为子域和允许凭据设置了 CORS。在响应中,我们可以看到这些被返回。
access-control-allow-credentials: true
access-control-allow-origin:从上面的子域
是否有任何原因未将 cookie 与请求一起发送到父域?我们已经注销了服务器端响应中的 cookie,但它们并不像我们预期的那样存在。
:authority: testing.parentdomain.com
:method: GET
:path: /basket/data/
:scheme: https
accept: /
accept-encoding: gzip, deflate, br
accept-language: en-GB,en;q=0.9, en-US;q=0.8
来源:https
://subdomain.testing.parentdomain.com …
我有一个像这样实施的守卫:
@Injectable()
export class CustomerGuard implements CanActivate {
constructor(
private authService: AuthenticationService,
private dialog: MatDialog
) { }
canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
if (this.authService.isCustomer) {
return true;
}
const dialog = this.dialog.open(SigninModalComponent, {
data: {
errorMessage: this.authService.isLoggedIn ?
'You don\t have access to this page, please use an appropriate account' :
'Please authenticate to access this page'
}
});
return dialog.afterClosed().pipe(
map(() => {
return this.authService.isCustomer;
})
);
}
}
Run Code Online (Sandbox Code Playgroud)
当我在浏览器的地址栏中键入未经授权的路由时,服务器端呈现显示惰性模式,然后当客户端接管时,会显示另一个工作模式,我可以成功验证并访问所请求的路由.
问题是服务器端渲染的模态永远不会消失......
是否有一个干净的解决方案,这并不意味着不显示服务器端的模式?
我想知道是否可以在 Angular 中的组件中使用箭头函数
<app-child [showItemCondition]="item => item.isVisible" [list]="items"></app-child>
Run Code Online (Sandbox Code Playgroud) 技术:Angular Cli、Angular version 7、Angular Google Maps、Firebase Functions。
问题:我正在尝试为我的 angular 通用应用程序提供服务,但在构建时遇到 angular google maps 错误。
我得到的错误:
/Users/test/Public/Leisure/leisure-app/functions/node_modules/@agm/core/services/managers/info-window-manager.js:1
(function (exports, require, module, __filename, __dirname) { import {
Observable } from 'rxjs';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
Run Code Online (Sandbox Code Playgroud)
似乎 Angular Universal 不喜欢第三方库。
我关注的资源: https : //hackernoon.com/deploying-angular-universal-v6-with-firebase-c86381ddd445
我的应用模块:
import { AgmCoreModule } from '@agm/core';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { AngularFireDatabase } from '@angular/fire/database';
import { AngularFireModule } from '@angular/fire';
import { ServiceWorkerModule …Run Code Online (Sandbox Code Playgroud) firebase angular-google-maps google-cloud-functions angular-universal angular
angular ×7
javascript ×4
typescript ×2
angular-cdk ×1
angular5 ×1
angular7 ×1
components ×1
cookies ×1
cors ×1
firebase ×1
jquery ×1
rest ×1
servlets ×1
setcookie ×1
types ×1
web.xml ×1