Skip to content
This repository was archived by the owner on Apr 30, 2018. It is now read-only.

Commit 4417dd2

Browse files
author
Harman Goei
committed
fix(fieldGroup): add shortcut for templateOptions
The shortcut is expected to be available in the template for fieldGroups now that they accept wrappers.
1 parent 8a542d5 commit 4417dd2

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/directives/formly-field.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ function formlyField($http, $q, $compile, $templateCache, $interpolate, formlyCo
204204
function setupFieldGroup() {
205205
$scope.options.options = $scope.options.options || {}
206206
$scope.options.options.formState = $scope.formState
207+
$scope.to = $scope.options.templateOptions
207208
}
208209
}
209210

src/directives/formly-form.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ describe('formly-form', () => {
287287
<div class="heading">
288288
Panel Title: {{options.templateOptions.title}}
289289
</div>
290+
<div class="sub-heading">
291+
Subtitle: {{to.subtitle}}
292+
</div>
290293
<div class="body">
291294
<formly-transclude></formly-transclude>
292295
</div>
@@ -300,6 +303,7 @@ describe('formly-form', () => {
300303
wrapper: 'panel',
301304
templateOptions: {
302305
title: 'My Panel',
306+
subtitle: 'is awesome',
303307
},
304308
fieldGroup: [
305309
getNewField(),
@@ -320,6 +324,10 @@ describe('formly-form', () => {
320324
expect(headingNode).to.exist
321325
const headingEl = angular.element(headingNode)
322326
expect(headingEl.text().trim()).to.eq('Panel Title: My Panel')
327+
const subHeadingNode = panelNode.querySelector('.sub-heading')
328+
expect(subHeadingNode).to.exist
329+
const subHeadingEl = angular.element(subHeadingNode)
330+
expect(subHeadingEl.text().trim()).to.eq('Subtitle: is awesome')
323331
})
324332

325333
it(`should be possible to hide a fieldGroup with the hide property`, () => {

0 commit comments

Comments
 (0)