어떻게 작동합니까? null로 표시됩니다. 파이어베이스 컬렉션이있는 각도 5
1
A
답변
0
다른 사람이 답을해야하는 경우 :
this.route.paramMap.subscribe(data => {
console.log('this routes to =>', data, name);
});
이 경로 매개 변수를 검색하면
this.route.paramMap.subscribe(params => {
this.name = params.get('id')
});
는 쿼리 연산자를 사용하는 경우 FireStore에서 일치하는 문서를 요청
-1
당신이해야한다고 생각 :
import { ActivatedRoute } from '@angular/router';
export class CategoriesComponent {
ngOninit() {
this.route$ = this.activatedRoute.queryParams.subscribe((params:
Params) => {
if (params) {
console.log(params['collection']);
} else {
console.log(params['items']);
}
});
이 데이터베이스 구조입니다 :는 TS 내가 경로로 제품
이의 이름을 기준으로 제품 페이지에 카테고리 페이지가 필요하다 URL 매개 변수를 구독하십시오. ngOnInit
ngOnInit() {
this.sub = this.route.params.subscribe(params => {
console.log(params['collection']);
console.log(params['items']);.
});
}
0
y의 구조와 이름에 대한 정보가 많지 않습니다. 우리의 Firestore 데이터베이스;
constructor(
public afAuth: AngularFireAuth,
db: AngularFirestore,
private route: ActivatedRoute,
private productsService: ProductsService,
private afs: AngularFirestore
) {
this.afAuth.auth.signInAnonymously();
this.user = this.afAuth.authState;
this.route.paramMap.subscribe(params => {
this.name = params.get('id')
});
}
ngOnInit() {
this.itemCollection = this.afs.collection<Item>('items', ref => {
return ref.where('name', '==', this.name);
});
this.items = this.itemCollection.valueChanges();
this.items.subscribe(data => {
console.log(data)
})
}
여기의 차이는 내가 먼저 생성자는 경로의 PARAMS에 가입하고 주소 표시 줄에서 이름을 검색 할 수 있다는 점이다 : 그러나,이 주사를. 당신이 당신의 라우터 모듈에 :id
라는 이름의 매개 변수를 가지고 있기 때문에
솔루션
, 당신은이 같은 식별자 매개 변수 값을 검색해야합니다. 이것은 나를 위해 일한
this.itemCollection = this.afs.collection<Item>('items', ref => {
return ref.where('name', '==', this.name);
});
+0
죄송합니다. 'name.'을'this.name' 대신에'ref.where()'메쏘드에 건네주었습니다. 이제 작동합니다. 이전 댓글을 삭제하십시오. – Trent
관련 문제
- 1. 파이어베이스 보안 (각도 파이팅)
- 2. 복잡한 파이어베이스 쿼리에 각도 서비스 만들기
- 3. 파이어베이스 항목이 각도 격자에 표시되지 않음
- 4. 각도 + 파이어베이스 - 데이터 입력 대기열을 제한 하시겠습니까?
- 5. 각도 5
- 6. 각도 5 서비스는 내가 5 각도 사용하고 지역 .json 파일
- 7. 각도 5 인증
- 8. JitCompilerFactory 각도 5
- 9. 각도 5 - 사업부
- 10. 토스터 숨기기 - 각도 5
- 11. 각도 5 흰색 화면
- 12. 오류 : "invalid_grant"각도 5
- 13. 원래 Toastr 각도 5?
- 14. 각도 5 - 웹팩 문제
- 15. 각도 5 환경
- 16. 각도 재질로 업그레이드하기 5
- 17. 각도 5 : 여러 관찰
- 18. 각도 5 StaticInjectorError : [Http]
- 19. 각도 (5) 입력 변수가
- 20. API 데이터 각도 5
- 21. 파이어베이스 고급 쿼리
- 22. 파이어베이스 제공자
- 23. 각도 파이어베이스 목록 개체를 반복하고 데이터를 가져 오는 방법
- 24. Typescript 각도 5 개체 상속
- 25. 리디렉션 오류 404 각도 5
- 26. 각도 5 : API 호출 직렬화
- 27. 각도 5 - TypeScript에서 문자열 번역
- 28. 각도 5 : 세션 객체는 JSON
- 29. 각도 5 GET 클래스 컨텍스트
- 30. 폼 빌더로 각도 5 폼
두 가지 모두에 대해 '정의되지 않음'이 표시됩니다. – Famous
URL은 어떤 모양입니까? –
다음은 공개 repo => https://bitbucket.org/FamousTM/angular5com – Famous