Encapsulated controller and app into an anonymous function