Siemens interview question

How to create a factory in angular js?