ported to angular. but many errors. need to fix.