Created
May 13, 2014 21:21
-
-
Save shadda/fcd1360146d466aa5df2 to your computer and use it in GitHub Desktop.
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
| PerfDB.app.directive('collection', function ($compile) | |
| { | |
| return { | |
| restrict: 'A', | |
| replace: true, | |
| require: '?ngModel', | |
| scope: { | |
| collection: '=' | |
| }, | |
| link: function($scope, $element, $attr, $ngModel) | |
| { | |
| if(Object.size($scope.collection.categories) > 0) | |
| { | |
| $compile('<optgroup class="collection" label="{{category.name}}" collection="category" ng-repeat="category in collection.categories"></optgroup>')($scope, function(cloned, scope) | |
| { | |
| $element.append(cloned); | |
| }); | |
| } | |
| if($scope.collection.children != undefined && $scope.collection.children.length) | |
| { | |
| $compile('<optgroup label="{{data.name}}" class="collection" leaf="child" ng-repeat="child in collection.children"></optgroup>')($scope, function(cloned, scope) | |
| { | |
| $element.append(cloned); | |
| }); | |
| } | |
| } | |
| } | |
| }); | |
| PerfDB.app.directive('leaf', function($compile) | |
| { | |
| return { | |
| restrict: 'A', | |
| replace: true, | |
| scope: { | |
| leaf: '=' | |
| }, | |
| link: function($scope, $element, $attrs) | |
| { | |
| $compile('<option class="leaf" value="{{leaf.id}}">{{leaf.name}}</option>')($scope, function(cloned, scope) | |
| { | |
| $element.replaceWith(cloned); | |
| }); | |
| } | |
| }; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment