Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- blender
- 디자인
- scss
- UX
- angular
- 생성AI
- UI
- 플랫폼
- Airtable
- 디자인 토큰
- CSS
- 업무자동화
- CINEMA4D
- 한글자동화
- 에러노트
- 데이터분석
- 에어테이블
- 프론트엔드
- 디자인토큰
- 파이썬
- chatGPT
- sass
- SaaS디자인
- 리액트
- three.js
- 문서자동화
- design token
- 3d
- 웹디자인
- frontend
Archives
- Today
- Total
이게 무슨 일이야!
[Angular 12] element 에 focus 주기 본문
Angular 에서 focus 주는건 간단한데 ... 원칙대로 했는데 안되서
여러가지 시도해서, 해결책을 찾아서 메모함
버전 : Angular 12
1. html (focus 주려는 애)
<div tabindex="0" #optionPanel></div>
2. .ts (focus 주는 애)
import {
ElementRef,
OnInit,
QueryList,
Renderer2,
ViewChild
} from '@angular/core';
export class IptSelectComponent implements OnInit {
...
@ViewChild('optionPanel', {static:true}) optionPanel:ElementRef;
...
openOptionPanel() {
this.optionPanel.nativeElement.focus();
//이 것만으로 focus 가 작동해야 하는데 안됐다 ㅠㅠ
setTimeout(()=>{
this.optionPanel.nativeElement.focus()
})
//setTimeout 에 넣으니까 100% 작동됨
}
setTimeout 안에 ~~.nativeElement.focus() 주니까 그제서야 작동..
뭔가의 트릭이긴한데 일단 작동시켜야 하니 쓴다
'프론트엔드 개발 > 개발 팁' 카테고리의 다른 글
| React build 하기 (0) | 2022.06.16 |
|---|---|
| node 버전 낮추기 (다운그레이드 하기) (0) | 2022.06.16 |
| 로컬 서버 세팅하기 (맥) (0) | 2022.05.31 |
| 리액트 개발중 메모메모.. (0) | 2022.05.23 |
| Private git clone 하기 (0) | 2022.04.13 |
Comments