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 316f53e

Browse files
committed
adding raw template to decorator
1 parent bb87620 commit 316f53e

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

‎src/services/builder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ angular.module('schemaForm').provider('sfBuilder', ['sfPathProvider', function(s
277277
*/
278278
build: function(form, decorator, slots, lookup) {
279279
return build(form, decorator, function(form, field) {
280-
if (form.type === 'template') {
281-
return form.template;
280+
if (field.type === 'template') {
281+
return field.template;
282282
}
283283
return $templateCache.get(field.template);
284284
}, slots, undefined, undefined, lookup);

‎test/services/decorators-test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,30 @@ describe('schemaFormDecorators', function() {
1616
var templateWithWrap = angular.element('<div id="wrap"><foobar form="{ type: \'foo\'}"></foobar></div>');
1717
var template = templateWithWrap.children().eq(0);
1818

19+
$compile(template)($rootScope);
20+
$rootScope.$apply();
21+
templateWithWrap.children().length.should.equal(1);
22+
templateWithWrap.children().is('foobar').should.be.true;
23+
templateWithWrap.children().eq(0).children().length.should.equal(1);
24+
templateWithWrap.children().eq(0).children().is('div').should.be.true;
25+
templateWithWrap.children().eq(0).children().hasClass('yes').should.be.true;
26+
});
27+
});
28+
});
29+
describe('#createDecoratorWithRawTemplate', function() {
30+
it('should enable you to create new decorator directives',function(){
31+
module(function(schemaFormDecoratorsProvider){
32+
schemaFormDecoratorsProvider.defineDecorator('foobar',{
33+
'foo': {template: '<div class="yes">YES</div>', replace: true, type: 'template'}
34+
},[angular.noop]);
35+
});
36+
37+
inject(function($rootScope,$compile){
38+
39+
//Since our directive does a replace we need a wrapper to actually check the content.
40+
var templateWithWrap = angular.element('<div id="wrap"><foobar form="{ type: \'foo\'}"></foobar></div>');
41+
var template = templateWithWrap.children().eq(0);
42+
1943
$compile(template)($rootScope);
2044
$rootScope.$apply();
2145
templateWithWrap.children().length.should.equal(1);

0 commit comments

Comments
(0)

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