我遇到了 Angular 的情况,其中路由数据解析器似乎准备正确返回数据,但解析从未发生。这特别奇怪,因为我有另一个组件的平行排列,并且在那里工作正常。
该应用程序通过 HTTP 检索有关一系列事件的数据。在 中EventListComponent
,解析器返回所有事件以响应/events
,并且组件正确显示它们。在一个EventDetails
组件中,在我目前的安排中,我仍然通过 HTTP 检索所有事件,然后在解析器中响应/events/[the event ID]
,选择应该显示其详细信息的事件。(这是来自 Pluralsight Angular Fundamentals 课程,以防它听起来很熟悉。但我倾向于观看视频,然后按照我自己的顺序完成它们,以尝试巩固我头脑中的技能。)
远程事件.service.ts
import { Injectable, EventEmitter } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { IEvent } from './event.model';
@Injectable()
export class RemoteEventService {
constructor(
private http: HttpClient
) {}
getEvents(): Observable<IEvent[]> {
return this.http.get<IEvent[]>('/api/ngfdata/events.json');
}
getEventById(id: number): Observable<IEvent> {
console.log(`In getEventById: id = ${id}`);
const emitter = new EventEmitter<IEvent>(); …
Run Code Online (Sandbox Code Playgroud) 我总是发现,当我在 SQL Server 中编程时,在我创建的所有内容都在架构下的数据库中dbo
,在查询表或视图或执行存储过程时不需要引用架构,但我总是需要在用户定义函数的调用前加上前缀,dbo.
否则解析器无法识别该名称。这是为什么?