Skip to content

Instantly share code, notes, and snippets.

@brendanmckenzie
Last active August 29, 2015 14:08
Show Gist options
  • Save brendanmckenzie/2510f8e009641a50ad91 to your computer and use it in GitHub Desktop.
Save brendanmckenzie/2510f8e009641a50ad91 to your computer and use it in GitHub Desktop.
(function (window) {
'use strict';
function ReferenceSelector(ReferenceSvc, $compile) {
var directive = {
restrict: 'E',
replace: true,
scope: {
model: '=xgModel'
},
template: '<select ng-options="a.id as a.displayText for a in options" ng-model="model"></select>'
};
directive.link = function (scope, element, attrs) {
ReferenceSvc.get(attrs.refType, function (data) {
scope.options = data;
});
}
return directive;
}
window.app.directive('referenceSelector', ['ReferenceSvc', '$compile', ReferenceSelector]);
})(window);
<reference-selector ref-type="ProfileMaritalStatus" xg-model="profile.maritalStatusId" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment