Revert commits from gh-pages
Change $scope.$apply calls to pass in function, so code run inside Angular context