티스토리 뷰
반응형
Html Textarea에 있는 내용을 줄바꿈 까지 String으로 저장해 DB에 넣었다가
나중에 불러오는 경우가 있다.
무조건적인 방법이 아니라 여러가지 방법중의 하나이다
예를들면 이런글을 DB에 넣고 싶다.
// Client단이나 Server단 중 어디서 처리를 하든 자유
//textarea안에서 사용할 줄바꿈은 db에 저장할 때 치환을 해야한다 replaceAll이 없어 정규화로 대체
notice.content=notice.content.replace(/(?:\r\n|\r|\n)/g,"
");
//정규화를 통한 br태그를 textarea 안에서 사용할 \r\n으로 치환
this.selectedNotice.content = this.selectedNotice.content.replace(/<br />/g,"\r\n");
그리고 이 글을 다시 원상태로 불러오고 싶을 때 에는
<div [innerhtml]="notice.data.content">
이런식으로 SENITIZATION 처리를 해줘야한다.
반응형
'FrontEnd > Angular' 카테고리의 다른 글
angular router popup (0) | 2018.08.07 |
---|---|
WARNING in Circular dependency detected (0) | 2018.08.06 |
RxJS (0) | 2018.07.31 |
localStroage에 json데이터 담기 (0) | 2018.07.23 |
RouterEvent의 Navigation Detect (0) | 2018.07.18 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- data grid component
- data gird component
- Java
- angular router
- JavaScript
- Angular
- react
- Spring Boot
- https://www.tistory.com/auth/logout/
- localStorage
- Spring
- Router
- JSON
- facebook login
- data component
- Redux
- data table component
- 페이스북 로그인
- data component module
- CSS
- jQuery
- JPA
- mobx
- 파이썬3
- 파이썬
- Python
- React-router
- MySQL
- python3
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함