為什麼需要用到 Decorators?
其一是你不想破壞原有的行為或是原有的程式碼,
去擴增或是覆寫現有功能,
之前一篇 JSNLog integrate to AngularJS 就是利用了 Decorator 裝飾掉 expectionHandle,
今天這篇主來更深入研究 AngularJS Decorator
為什麼需要用到 Decorators?
其一是你不想破壞原有的行為或是原有的程式碼,
去擴增或是覆寫現有功能,
之前一篇 JSNLog integrate to AngularJS 就是利用了 Decorator 裝飾掉 expectionHandle,
今天這篇主來更深入研究 AngularJS Decorator
基於上一篇提到的在前端紀錄 log 會有個問題
如果拋出錯的程式碼沒有用 try catch 包起來就無法紀錄 log
AngularJS 提供了 $exceptionHandler 這個好用的東西
在 「Angular 世界」中可以攔截到任何 uncaught exception