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

Commit 572353d

Browse files
author
Kent C. Dodds
committed
grunt build
1 parent 8f87532 commit 572353d

File tree

6 files changed

+66
-12
lines changed

6 files changed

+66
-12
lines changed

dist/formly.bootstrap.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,50 @@ angular.module('formly.render').directive('formlyForm', [
6565
'formlyOptions',
6666
'$compile',
6767
function formlyForm(formlyOptions, $compile) {
68+
var templateHide = 'ng-hide="field.hide"';
69+
var fieldsTemplate = [
70+
'<formly-field ng-repeat="field in fields"',
71+
'options="field"',
72+
'form-result="result"',
73+
'form-value="result[field.key||$index]"',
74+
'form-id="options.uniqueFormId"',
75+
'ng-hide="field.hide"',
76+
'index="$index">',
77+
'</formly-field>'
78+
].join(' ');
6879
return {
6980
restrict: 'AE',
70-
templateUrl: 'directives/formly-form.html',
81+
template: function (el, attr) {
82+
var useNgIf = formlyOptions.getOptions().useNgIfToHide;
83+
return [
84+
'<form class="formly" role="form">',
85+
'<div class="ng-hide">fields</div>',
86+
'<button type="submit"',
87+
'ng-show="!options.hideSubmit">',
88+
'{{options.submitCopy || "Submit"}}',
89+
'</button>',
90+
'</form>'
91+
].join(' ');
92+
},
7193
replace: true,
7294
scope: {
7395
fields: '=',
7496
options: '=?',
7597
result: '=',
7698
formOnParentScope: '=name'
7799
},
78-
compile: function (scope, iElement, iAttrs, controller, transcludeFn) {
100+
compile: function () {
79101
return {
80102
post: function (scope, ele, attr, controller) {
81103
scope.options = angular.extend(formlyOptions.getOptions(), scope.options);
82104
if (scope.options.submitButtonTemplate) {
83105
ele.find('button').replaceWith($compile(scope.options.submitButtonTemplate)(scope));
84106
}
107+
var template = fieldsTemplate;
108+
if (scope.options.useNgIfToHide) {
109+
template = template.replace(templateHide, 'ng-if="!field.hide"');
110+
}
111+
ele.find('div').replaceWith($compile(template)(scope));
85112
//Post gets called after angular has created the FormController
86113
//Now pass the FormController back up to the parent scope
87114
scope.formOnParentScope = scope[attr.name];
@@ -134,7 +161,8 @@ angular.module('formly.render').provider('formlyOptions', function () {
134161
uniqueFormId: null,
135162
submitCopy: 'Submit',
136163
hideSubmit: false,
137-
submitButtonTemplate: null
164+
submitButtonTemplate: null,
165+
useNgIfToHide: false
138166
};
139167
function setOption(name, value) {
140168
if (typeof name === 'string') {

dist/formly.bootstrap.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)