Skip to content

Commit

Permalink
LIVIJUKU-253
Browse files Browse the repository at this point in the history
Scopeton transcludaaminen komponentteihin jotka ei tarvi omaa scopea.
angular/angular.js#5489
  • Loading branch information
rikukissa committed Jun 16, 2015
1 parent 409ff45 commit 44cc9ee
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
13 changes: 6 additions & 7 deletions app/scripts/components/form/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

module.exports = function () {
return {
transclude: true,
replace: true,
template: `
<form class="form" ng-transclude></form>`
};
var transclude = require('utils/transclude');

module.exports = function() {
return transclude({
template: `<form class="form"></form>`
});
};
13 changes: 6 additions & 7 deletions app/scripts/components/formRow/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

module.exports = function () {
return {
transclude: true,
replace: true,
template: `
<div class="form-row" ng-transclude></div>`
};
var transclude = require('utils/transclude');

module.exports = function() {
return transclude({
template: `<div class="form-row"></div>`
});
};
13 changes: 6 additions & 7 deletions app/scripts/components/formSection/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

module.exports = function () {
return {
transclude: true,
replace: true,
template: `
<div class="form-section" ng-transclude></div>`
};
var transclude = require('utils/transclude');

module.exports = function() {
return transclude({
template: `<div class="form-section"></div>`
});
};
15 changes: 15 additions & 0 deletions app/scripts/utils/transclude.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

var _ = require('lodash');

module.exports = function transclude(options) {
return _.extend({
transclude: true,
replace: true,
link(scope, element, attr, controller, transcludeFn) {
transcludeFn(scope, function (clone) {
element.empty().append(clone);
});
}
}, options);
};

0 comments on commit 44cc9ee

Please sign in to comment.