Updated to play nice with angularjs when using variables that are promises that eventually resolve to a string