angular.module('APP', []).controller('MainController', function($scope, UserConstants){ var user = { firstName: 'Benjamin', lastName: 'Roth' }; this.user = user; this.userTypes = UserConstants.types;}).service('UserPresenter', function(UserConstants){ var typeFromId = _.memoize(function(typeId){ var obj = _.findWhere(UserConstants.types, { value: typeId}); return obj ? obj.display : ''; }); return { fullName: function(user){ return user.firstName + ' ' + user.lastName; }, type: function(user){ return typeFromId(user.typeId); } };}).factory('UserModel', function(UserPresenter){ function UserModel(props){ _.extend(this, props); } UserModel.prototype.fullName = function(){ return UserPresenter.fullName(this); }; UserModel.prototype.type = function(){ return UserPresenter.type(this); }; return UserModel;}).filter('user', function(UserPresenter){ return function(user, fnName){ return UserPresenter[fnName](user); };}).constant('UserConstants', { types: [ { value: '1', display: 'Front end' }, { value: '2', display: 'Back end' }, { value: '3', display: 'Full stack' } ]});
JS Bin { { main.user | json}}