See http://plnkr.co/edit/LRnsWG9w5JNyciwO1LgR?p=preview