wrapped demo code into angular.js