fixed javascript to call database through angular