Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit daecafe

Browse files
committed
adding raw template to decorator
1 parent 1af2292 commit daecafe

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

‎src/services/schema-form-decorators.provider.spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,30 @@ describe('schemaFormDecorators', function() {
5050
});
5151
});
5252
});
53+
54+
describe('#legacy #defineDecoratorWithRawTemplate', function() {
55+
it('should enable you to create new decorator directives',function(){
56+
module(function(schemaFormDecoratorsProvider){
57+
schemaFormDecoratorsProvider.defineDecorator('foobar',{
58+
'foo': {template: '<div class="yes">YES</div>', replace: true, type: 'template'}
59+
},[angular.noop]);
60+
});
61+
62+
inject(function($rootScope,$compile){
63+
64+
//Since our directive does a replace we need a wrapper to actually check the content.
65+
var templateWithWrap = angular.element('<div id="wrap"><foobar form="{ type: \'foo\'}"></foobar></div>');
66+
var template = templateWithWrap.children().eq(0);
67+
68+
$compile(template)($rootScope);
69+
$rootScope.$apply();
70+
templateWithWrap.children().length.should.equal(1);
71+
templateWithWrap.children().is('foobar').should.be.true;
72+
templateWithWrap.children().eq(0).children().length.should.equal(1);
73+
templateWithWrap.children().eq(0).children().is('div').should.be.true;
74+
templateWithWrap.children().eq(0).children().hasClass('yes').should.be.true;
75+
});
76+
});
77+
});
78+
5379
});

‎src/services/sf-builder.provider.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ export default function(sfPathProvider) {
326326
*/
327327
build: function(form, decorator, slots, lookup) {
328328
return build(form, decorator, function(form, field) {
329-
if (form.type === 'template') {
330-
return form.template;
329+
if (field.type === 'template') {
330+
return field.template;
331331
}
332332
return $templateCache.get(field.template);
333333
}, slots, undefined, undefined, lookup);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /