Skip to content

Instantly share code, notes, and snippets.

@aantipov
Created September 14, 2014 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aantipov/dfc1c10e0f7233aa7828 to your computer and use it in GitHub Desktop.
Save aantipov/dfc1c10e0f7233aa7828 to your computer and use it in GitHub Desktop.
Example of directive with the use of transcludeFn
'use strict';
angular.module('angularjs.module')
.directive('multiSelect', function ($modal, $templateCache, gettextCatalog) {
return {
restrict: 'A',
priority: 1000,
scope: {
dataLength: '@length',
title: '@'
},
transclude: true,
templateUrl: '/components/common/multiSelect.html',
link: function (scope, iElement, attr, ctrl, transclude) {
iElement.find('.transcluded').append(transclude(scope.$parent, angular.noop));
scope.showModal = function () {
var modal = $modal({
title: scope.title || gettextCatalog.getString('Select options'),
template: '/components/common/multiSelectModal.html',
show: false
});
modal.$promise.then(function () {
modal.show();
$('#id-multiselect-modal .modal-body').append(transclude(scope.$parent, angular.noop));
});
};
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment