根据WAI-ARIA 规范,两个角色都应该具有:
aria-label设置我看到的唯一区别是alertdialog应该aria-describedby设置。
这让我想到一个问题。role=dialog和之间的实际区别是role=alertdialog什么?我们什么时候使用一种或另一种?
我收到了一个传给formControl的@Input参数,该参数绑定到最大值应该为10的数字类型的输入。当用户键入更大的数字时,它不应更改输入值。
如何防止事件传播或获取旧值并重新设置?
我尝试了来自堆栈和github的许多其他解决方案,但是没有什么能解决我的问题。
valuecontrol: FormControl = new FormControl(0);
constructor(){
this.control.valueChanges.pipe(distinctUntilChanged()).subscribe(newValue=>{
if(newValue >= 10){
// set previous value
const oldValue = this.control.value;
console.log("old value = ", oldValue)
this.control.patchValue(oldValue);
}
})
}.
Run Code Online (Sandbox Code Playgroud)
演示:https : //stackblitz.com/edit/angular-6ocjfj? file = src/app/ app.component.ts
我得到了 3 个返回即将发生的、当前的、过去的事件的端点。我应该只展示未来最远的那个。为了优化调用而不是一次调用所有端点。我编写了一个简单的 RxJs 流,在其中调用第一个端点,如果它不返回数据,则调用第二个,依此类推。代码如下所示:
this.eventsService.getUpcoming(id).pipe(
switchMap((upcoming) => {
if (upcoming.length) {
return of(upcoming);
}
return this.eventsService.getCurrent(id).pipe(
switchMap((current) => {
if (current.length) {
return of(current);
}
return this.eventsService.getPast(id)
})
);
}),
// some other pipe operators map etc.
Run Code Online (Sandbox Code Playgroud)
开关映射中可能没有嵌套的开关映射吗?
我需要canDeactivate向我的应用程序路由之一添加防护。在该函数中,我调用本机confirm函数以确认用户是否确实想要离开页面。如果用户走非守卫保护路线似乎一切都很好。
然而,当用户重定向到有一个守卫重定向到另一个页面的路由时,就会出现问题。然后发生的事情是确认弹出窗口出现两次。
我创建了一个简单的复制品。https://stackblitz.com/edit/can-activate-deactive-problem。
有没有什么方法可以解决这个问题而不需要一些hacky解决方案?
可以停用.guard.ts
@Injectable({ providedIn: 'root' })
export class CanDeactivateGuard implements CanDeactivate<any> {
canDeactivate(): Observable<boolean> | Promise<boolean> | boolean {
return confirm('are you sure you want to leave?');
}
}
Run Code Online (Sandbox Code Playgroud)
可以激活.guard.ts
export class CanActivateGuard implements CanActivateGuard {
constructor(private router: Router) {}
canActivate(): Observable<boolean> | Promise<boolean> | boolean {
this.router.navigate(['/not-allowed']);
return false;
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个非常直接的.net核心应用程序,它使用REST向mongo db添加和下载对象.添加项目非常有效.获取包含所有项目的列表,但是当我尝试id每次使用时都使用它null.我应该改变什么来使这段代码工作.这意味着当数据库中存在一个匹配项时,使用它的唯一ID从数据库中获取Tool对象.
private IMongoCollection<Tool> Tools => _database.GetCollection<Tool>("Tools");
public async Task<Tool> GetAsync(Guid id) =>
await Tools.AsQueryable().FirstOrDefaultAsync(tool => tool.Id == id);
Run Code Online (Sandbox Code Playgroud)
当我在调试器中检查时,参数看起来像那样 "{ee1aa9fa-5d17-464c-a8ba-f685203b911f}"
编辑
工具类属性
public Guid Id { get; protected set; }
public string Model { get; protected set; }
public string Brand { get; protected set; }
public string Type { get; protected set; }
public uint Box { get; protected set; }
Run Code Online (Sandbox Code Playgroud)
修正了检查评论
angular ×3
.net ×1
angular7 ×1
c# ×1
html ×1
javascript ×1
mongodb ×1
rxjs ×1
typescript ×1
wai-aria ×1