Skip to content

Instantly share code, notes, and snippets.

@brendanmckenzie
Created October 29, 2014 04:58
Show Gist options
  • Save brendanmckenzie/91ff3a962032995e16c5 to your computer and use it in GitHub Desktop.
Save brendanmckenzie/91ff3a962032995e16c5 to your computer and use it in GitHub Desktop.
(function (window) {
'use strict';
function ReferenceSelector($http) {
var directive = {
restrict: 'E',
replace: true,
scope: {
model: '=ngModel',
disabled: '=ngDisabled'
}
};
directive.template = '<select ng-options="a.id as a.displayText for a in options"></select>';
directive.link = function (scope, element, attrs) {
$http.get('/api/references/' + attrs.type).success(function (data) {
scope.options = data;
});
}
return directive;
}
window.app.directive('referenceSelector', ['$http', ReferenceSelector]);
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment