Added partial to reduce duplication, need to extract logic out of view and into controller (angularjs)