Created
June 6, 2016 16:35
-
-
Save rnaffer/4b42f73814aa7c25a8500f68ad4ddb27 to your computer and use it in GitHub Desktop.
ui-select Required Directive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.directive('uiSelectRequired', function() { | |
| return { | |
| require: 'ngModel', | |
| link: function(scope, elm, attrs, ctrl) { | |
| ctrl.$validators.uiSelectRequired = function(modelValue, viewValue) { | |
| for(var prop in modelValue) { | |
| if(modelValue.hasOwnProperty(prop)) | |
| return true; | |
| } | |
| return false && JSON.stringify(modelValue) !== JSON.stringify({}); | |
| }; | |
| } | |
| }; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment