refactoring of object into directive. fixed error after uglify (mangling)