학문의 길/Angular 5

Modal 띄우기

Angular에서 Modal띄우는 방법.순수 javascript modal과 약간 다르다. Installnpm install angular-custom-modal Usageapp.module.tsimports: [ ... ModalModule, ... ], ... }) http://jasonwatmore.com/post/2017/01/24/angular-2-custom-modal-window-dialog-box나머지는 여기 보로 따라하면 된다. 아래는 내가 사용했던 소스 html {{modalText}} 확인 componentopenUrlModal(){ this.modalText="URL이 클립보드에 복사되었습니다." this.modalService.open('url-modal'); } closeModa..

타입단언 as Type, <Type>

vs as Type타입 단언 문법은 과 as Type 으로 두 종류다. 아래처럼 사용할 수 있다.1 2 (character).fireBall(); (character as Wizard).fireBall(); 그냥 보기에는 키워드가 좀 더 깔끔해보이지만, 대개 as Type 키워드가 추천된다. React 와 React 에서 빼놓을 수 없는 문법인 JSX 를 사용하는 경우 키워드는 JSX 의 문법과 겹치기 때문에 불편한 면이 있다. *내가 봤던 경우this.context = (this.myCanvas.nativeElement).getContext('2d'); this.context = (this.myCanvas.nativeElement as HTMLCanvasElement).getContext('2d');

Canvas 사용하기

1. 검색해서 나온 것처럼 getElement.. 이런거 쓰면 잘 안된다. Angular방식이 따로 있음. 2. HTML소스에 이렇게 넣고.. 3. 요런식으로 쓴다 import { ViewChild, ElementRef } from '@angular/core'; ... // Somewhere above your class constructor @ViewChild('myCanvas') myCanvas: ElementRef; public context: CanvasRenderingContext2D; // Somewhere under the class constructor we want to wait for our view // to initialize ngAfterViewInit(): void { this...