UNPKG

landers.angular

Version:

landers.angular

25 lines (24 loc) 1.09 kB
;angular.module('Landers.angular') .directive('landersTreeSelect', ['$timeout', function($timeout) { return { restrict : 'A', require: 'ngModel', link : function($scope, $element, $attrs, ngModel){ var source = $attrs.source; var root_text = $attrs.rootText || '请选择栏目'; var root_value = $attrs.rootValue || ''; $scope.$watch(source, function(newValue){ $element.children().remove(); Landers.treeselect.select({ contain: $element, data:newValue, root:[root_value, root_text] }); var precache = $element.data('precache'); $element.val(precache); }); $scope.$watch($attrs['ngModel'], function(newValue){ $element.data('precache', newValue); $element.val(newValue); }); } }; }]);