convert atmosphere javascript to angularJs