我正在尝试实现Angular Material 2,MatPaginator服务器端分页..我该如何实现?
下面是代码示例:
<div class="example-container mat-elevation-z8">
<mat-table #table [dataSource]="dataSource">
<!-- Position Column -->
<ng-container matColumnDef="position">
<mat-header-cell *matHeaderCellDef> No. </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.position}} </mat-cell>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef> Name </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.name}} </mat-cell>
</ng-container>
<!-- Weight Column -->
<ng-container matColumnDef="weight">
<mat-header-cell *matHeaderCellDef> Weight </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.weight}} </mat-cell>
</ng-container>
<!-- Symbol Column -->
<ng-container matColumnDef="symbol">
<mat-header-cell *matHeaderCellDef> Symbol </mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.symbol}} </mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: …Run Code Online (Sandbox Code Playgroud) 我的 shell 和微前端有单独的存储库,我想在 shell 和微前端之间共享身份验证服务数据。
我使用下面的文章“第 5 步:共享 Monorepo 的库”来创建 AuthService 共享库,但由于我的不是 Monorepo,所以我将该库发布到 npm 中:
我的 AuthLibrary 的 npm:https://www.npmjs.com/package/@vijender1256/auth-lib
我将 npm 包安装到我的 shell 和微前端中。我正在 shell 应用程序中设置登录值,并希望在多个微前端中共享用户信息,我想使用此库进行跨 shell 和微前端的 AuthService 状态管理。
shell webpack.config.js
const { shareAll, withModuleFederationPlugin } = require('@angular-architects/module-federation/webpack');
module.exports = withModuleFederationPlugin({
shared: {
...shareAll({ singleton: true, strictVersion: true, eager: true, requiredVersion: 'auto' }),
...sharedMappings.getDescriptors()
},
sharedMappings: ['@vijender1256/auth-lib'],
});
Run Code Online (Sandbox Code Playgroud)
微前端 webpack.config.js:
const { shareAll, withModuleFederationPlugin } = require('@angular-architects/module-federation/webpack');
module.exports = withModuleFederationPlugin({
name: 'itemMfe',
exposes: {
'./ItemModule': …Run Code Online (Sandbox Code Playgroud) angular angular-library webpack-module-federation angular-module-federation
我有一个基于 .NET core 的微服务架构,并且有几个微服务。我们选择 ocelot 作为 API 网关来实现路由、聚合和安全。在我们的架构讨论中,有人提到 Envoy Api Gateway 也是一个不错的选择,但找不到 Ocelot 和 Envoy 之间的任何差异,它的优缺点包括性能、可扩展性、社区支持等......
任何人都可以帮助分享一些关于哪一个是用于 .NET Core 应用程序的最佳选择的见解吗?
我试图通过在任务运行器资源管理器中将watch的绑定属性设置为'After Build'来运行gulp watch.我尝试运行应用程序,在构建期间它从gulp触发我的监视任务并且它仍在运行.但我的应用程序没有在浏览器中运行,它只是挂在visual studio屏幕上.
在我停止监视任务后,我的项目运行,我可以在浏览器中看到我的应用程序.我注意到当你运行项目监视时,由一个线程触发,直到它被关闭,它不允许我的应用程序在浏览器中运行和打开.
我如何解决它.任何有用的帮助.
gulp.task('watch', ['compile', 'resources'], function () {
gulp.watch(["src/**/*", "!**/*.ts"], ['resources']);
gulp.watch("src/**/*.ts", ['compile']);
});
Run Code Online (Sandbox Code Playgroud)
以上是我的gulp手表,我将其设置为在构建任务运行器资源管理器后运行.
我有以下代码可以在本地开发期间绕过添加身份验证,我正在使用 Azure AD 和 .NET Core。
#if !DEBUG
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(Configuration.GetSection("AzureAd"));
#endif
Run Code Online (Sandbox Code Playgroud)
但是,由于我的控制器受 Authorize 属性保护,因此如何在本地开发期间绕过 Controller 内的 Authorize 属性:
[Authorize(Roles = "Buyer")]
public class ProductController : ApiBaseController
{
}
Run Code Online (Sandbox Code Playgroud)
在 .NET Framework 中,我有以下代码来覆盖 Authorize 属性:
public class MyAuthorizeAttribute : AuthorizeAttribute
{
#if DEBUG
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
return true;
}
#endif
}
Run Code Online (Sandbox Code Playgroud)
.NET Core 的等效代码是什么?或者有没有其他方法可以覆盖 Startup.cs 类中的 Authorize 属性?
c# .net-core asp.net-core asp.net-core-webapi asp.net-core-3.1
我创建了一个示例plunker,将多个参数传递到下一页,但它不起作用.这是一个plunker演示,点击项目后危机中心路由不起作用.
http://plnkr.co/edit/ngNSsKBzAuhaP0EjKVJX?p=preview
onSelect(crisis: Crisis) {
// Navigate with Absolute link
//this.router.navigate(['/crisis-center', 1]); //this is working.
this.router.navigate(['/crisis-center', { id: '1', id2:'2'}]); //this is not working
}
Run Code Online (Sandbox Code Playgroud)
//下面是路线:
//{ path: 'crisis-center/:id', component: CrisisDetailComponent } //-- this is working
{ path: 'crisis-center/:id /:id2', component: CrisisDetailComponent}, // this is not working
ngOnInit() {
this.sub = this.route
.params
.subscribe(params => {
let id = +params['id'];
let id2 = +params['id2']; //Unable to read id and id2 values
this.service.getCrisis(id)
.then(crisis => {
if (crisis) {
this.editName = …Run Code Online (Sandbox Code Playgroud) 我具有不同的用户角色,并且基于登录的用户角色,我想在登录后更改默认页面(登录页面)。我该如何实现它,还没有在线找到任何资源,是否需要尚未实施,或者我缺少一些东西:
我有两个模块ExceptionDashboard和CashierRiskprofile模块路由
import { Routes, RouterModule } from "@angular/router";
import { CashierRiskProfileComponent } from "./cashierriskprofile.component";
const cashierRiskProfileRoutes: Routes = [
{ path: "", redirectTo: "cashierriskprofile", pathMatch: "full" },
{ path: "cashierriskprofile", component: CashierRiskProfileComponent }
];
export const CashierRiskProfileRouting = RouterModule.forChild(cashierRiskProfileRoutes);
Run Code Online (Sandbox Code Playgroud)
上面的代码将默认路径设置为cashierRiskprofile。
ExceptionDashboard:
const exceptionDashboardRoutes: Routes = [
{ path: "exceptionDashboard", component: ExceptionDashboardComponent, pathMatch: 'full' },
{ path: "exceptionDetail", component: ExceptionDetailComponent, pathMatch: 'full' },
{ path: "exceptionTransaction", component: ExceptionTransactionComponent, pathMatch: 'full' }
];
Run Code Online (Sandbox Code Playgroud)
对于Admin用户,我们将CashierRiskProfile显示为已经默认的登录页面,对于其他用户,我想将exceptionDashboard路径显示为登录页面。如何基于UserRole进行更改。
我知道如何实现CanActivateViaAuthGuard“ canActivate”服务以在用户未通过身份验证的情况下重定向到特定页面,但是我正在考虑根据用户角色更改登录页面?
import { Injectable } from …Run Code Online (Sandbox Code Playgroud) 我们有两个数据库,一个在 SQL Server 中,一个在 DB2 中,我们有一个场景,我们在 SQL Server 中进行一些数据插入、数据更新和删除,同时我们也在 Db2 中进行数据插入、更新和删除。
我们使用一些进程来回同步数据,每当 SQL Server 发生更改时,我们都会将数据同步到 db2 进行插入、更新和删除,如果 db2 发生更改,我们会将数据同步到 SQL Server,我们使用 IBM MQ 消息我们将消息出队以来回同步更改。
一切都很好,直到我们遇到了从 Db2 到 SQL Server 的数据同步问题,我们的一个进程停止了从 db2 到 SQL Server 的同步,因此有一个每天晚上运行的按需作业,将从 Db2 进行完整的数据刷新到SQL Server,但我们只进行合并更新和插入,我们不进行删除,因为尚未同步到db2的数据也存在于SQL Server中,因此我们不能直接删除,因为两个数据库都可以有更多或更少的记录,因此 SQL Server 上的数据中的一些数据是孤立的,我们有一个范围,因此在 SQL Server 中更新的数据不能在 db2 中更改,反之亦然。
我的问题是,当我们从 Db2 同步到 SQL Server 时,如何识别从 db2 中删除的记录,以便我们可以从 SQL Server 中删除这些记录,我们不想删除在 SQL Server 中创建但尚未删除的记录发送到 db2,我们有 114 个表,如果可以选择区分,我们无法维护标志。
订阅中的变量未定义,但是当我在点击服务订阅之前放置断点时,我定义了变量。
服务中:
getCashierRiskProfiles(): Observable<ICashierRiskProfile[]> {
return this.http.get(this._baseUrl + "src/HTTPJson/cashierriskprofile.json")
.map((res: Response) => res.json())
.catch((error: any) => Observable.throw(error.json().error || 'Server error'));
}
Run Code Online (Sandbox Code Playgroud)
在组件中:
import { Component, OnInit } from "@angular/core";
import { Observable } from 'rxjs/Observable';
import { CashierRiskProfileService } from "./cashierriskprofile.service";
import { ICashierRiskProfile } from "../shared/interfaces";
@Component({
selector: "cashierriskprofile",
templateUrl: "../src/app/cashierriskprofile/cashierriskprofile.component.html"
})
export class CashierRiskProfileComponent implements OnInit {
filterText: string;
cashierRiskProfiles: ICashierRiskProfile[];
constructor(
private sorter: Sorter,
private service: CashierRiskProfileService
) { }
ngOnInit() {
this.filterText = "Filter Exceptions:";
//// …Run Code Online (Sandbox Code Playgroud) 我有一个用于读取和写入操作的 SQL Server 数据库,并且我正在实现 CQRS 模式以实现代码隔离和可维护性,以便我可以将读取操作分配给团队中的少数资源,并将写入操作分配给其他资源,我认为使用 CQRS 似乎采取干净的方法。
现在,每当我的数据库中的表上发生插入/更新/删除时,我需要向需要了解我的系统中的更改的其他系统发送消息,因为我的数据库是主数据,因此这里发生的任何更改都需要投射到下游系统,以便他们获取最新数据并将其维护在自己的系统中。为此,我可以使用 MQ 或 Kafka,因此每当有变化时,我都可以生成关键消息并放入 MQ 中或使用 kafka 进行消息传递。
到目前为止,我还没有像我想象的那样使用事件源,因为我没有多个数据库用于读/写,所以我可能不需要事件源,我的假设是否正确,如果我们有单个数据库,我们就不需要事件源?或事件源可以在利用 MQ 或 Kafka 中发挥任何作用,我的意思是,如果我使用事件源模式,我可以首先将数据保存在主数据库中,然后使用事件源模式将更改写入 MQ 或使用 kafka 写入消息,我一无所知在这里,我们是否可以使用 MQ 或 Kafka 的事件源模式。
将消息写入 MQ 或使用 Kafka 是否需要事件源?或者在我的情况下根本不需要,因为我只有一个数据库,我不需要知道记录系统发生的一系列更新,我关心的是主数据库中记录的最终状态然后使用 MQ 或 Kafka 将更改发送到有 CRUD 操作的下游系统,以便下游系统获得最新的更改。
angular ×5
.net-core ×2
sql-server ×2
apache-kafka ×1
asp.net-core ×1
c# ×1
cqrs ×1
db2 ×1
envoyproxy ×1
gulp ×1
gulp-watch ×1
ocelot ×1
rabbitmq ×1
rxjs ×1