port to Angular JS