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

Commit 1093185

Browse files
committed
version 0.0.12 + build
1 parent cb3c8fc commit 1093185

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-formly",
3-
"version": "0.0.11",
3+
"version": "0.0.12",
44
"authors": [
55
"Astrism <[email protected]>"
66
],

dist/formly.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,30 @@ angular.module('formly.render').directive('formlyForm', [
9292
'$element',
9393
'$parse',
9494
function ($scope, $element, $parse) {
95+
// setup watches for watchExpressions
96+
angular.forEach($scope.fields, function (field, index) {
97+
if (angular.isDefined(field.watch)) {
98+
var watchExpression = field.watch.expression;
99+
if (angular.isFunction(watchExpression)) {
100+
// wrap the field's watch expression so we can call it with the field as the first arg as a helper
101+
watchExpression = function () {
102+
var args = Array.prototype.slice.call(arguments, 0);
103+
args.unshift(field);
104+
return field.watch.expression.apply(this, args);
105+
};
106+
}
107+
$scope.$watch(watchExpression, function () {
108+
// wrap the field's watch listener so we can call it with the field as the first arg as a helper
109+
var args = Array.prototype.slice.call(arguments, 0);
110+
args.unshift(field);
111+
return field.watch.listener.apply(this, args);
112+
});
113+
}
114+
});
95115
$scope.$watch('result', function (newValue) {
96116
angular.forEach($scope.fields, function (field, index) {
97117
if (field.hideExpression) {
98-
var getter = $parse(field.hideExpression);
99-
field.hide = getter($scope.result);
118+
field.hide = $parse(field.hideExpression)($scope.result);
100119
}
101120
});
102121
}, true);
@@ -168,14 +187,14 @@ angular.module('formly.render').run([
168187
'$templateCache',
169188
function ($templateCache) {
170189
'use strict';
171-
$templateCache.put('directives/formly-field-checkbox.html', '<div class=checkbox><label><input type=checkbox ng-required=options.required ng-disabled=options.disabled ng-model=value>{{options.label || \'Checkbox\'}} {{options.required ? \'*\' : \'\'}}</label></div>');
190+
$templateCache.put('directives/formly-field-checkbox.html', '<div class=checkbox><label><input type=checkbox ng-required=options.required ng-disabled=options.disabled ng-model=value> {{options.label || \'Checkbox\'}} {{options.required ? \'*\' : \'\'}}</label></div>');
172191
$templateCache.put('directives/formly-field-email.html', '<div class=form-group><label for={{id}}>{{options.label || \'Email\'}} {{options.required ? \'*\' : \'\'}}</label><input type=email class=form-control id={{id}} placeholder={{options.placeholder}} ng-required=options.required ng-disabled=options.disabled ng-model=value></div>');
173192
$templateCache.put('directives/formly-field-hidden.html', '<input type=hidden ng-model=value>');
174193
$templateCache.put('directives/formly-field-number.html', '<div class=form-group><label for={{id}}>{{options.label || \'Number\'}} {{options.required ? \'*\' : \'\'}}</label><input type=number class=form-control id={{id}} placeholder={{options.placeholder}} ng-required=options.required ng-disabled=options.disabled min={{options.min}} max={{options.max}} ng-minlength={{options.minlength}} ng-maxlength={{options.maxlength}} ng-model=value></div>');
175194
$templateCache.put('directives/formly-field-password.html', '<div class=form-group><label for={{id}}>{{options.label || \'Password\'}} {{options.required ? \'*\' : \'\'}}</label><input type=password class=form-control id={{id}} ng-required=options.required ng-disabled=options.disabled ng-model=value></div>');
176-
$templateCache.put('directives/formly-field-radio.html', '<div class=radio-group><label class=control-label>{{options.label}} {{options.required ? \'*\' : \'\'}}</label><div class=radio ng-repeat="(key, option) in options.options"><label><input type=radio name={{id}} id="{{id + \'_\'+ $index}}" ng-value=option.value ng-required=options.required ng-model=$parent.value>{{option.name}}</label></div></div>');
195+
$templateCache.put('directives/formly-field-radio.html', '<div class=radio-group><label class=control-label>{{options.label}} {{options.required ? \'*\' : \'\'}}</label><div class=radio ng-repeat="(key, option) in options.options"><label><input type=radio name={{id}} id="{{id + \'_\'+ $index}}" ng-value=option.value ng-required=options.required ng-model=$parent.value> {{option.name}}</label></div></div>');
177196
$templateCache.put('directives/formly-field-select.html', '<div class=form-group><label for={{id}}>{{options.label || \'Select\'}} {{options.required ? \'*\' : \'\'}}</label><select class=form-control id={{id}} ng-model=value ng-required=options.required ng-disabled=options.disabled ng-init="value = options.options[options.default]" ng-options="option.name group by option.group for option in options.options"></select></div>');
178-
$templateCache.put('directives/formly-field-text.html', '<div class=form-group><label for={{id}}>{{options.label || \'Text\'}} {{options.required ? \'*\' : \'\'}}</label><input class=form-control id={{id}} placeholder={{options.placeholder}} ng-required=options.required ng-disabled=options.disabled ng-model=value></div>');
197+
$templateCache.put('directives/formly-field-text.html', '<div class=form-group><label for={{id}}>{{options.label || \'Text\'}} {{options.required ? \'*\' : \'\'}}</label><input type=text class=form-control id={{id}} placeholder={{options.placeholder}} ng-required=options.required ng-disabled=options.disabled ng-model=value></div>');
179198
$templateCache.put('directives/formly-field-textarea.html', '<div class=form-group><label for={{id}}>{{options.label || \'Text\'}} {{options.required ? \'*\' : \'\'}}</label><textarea type=text class=form-control id={{id}} rows={{options.lines}} placeholder={{options.placeholder}} ng-required=options.required ng-disabled=options.disabled ng-model=value>\n' + '\t</textarea></div>');
180199
$templateCache.put('directives/formly-field.html', '');
181200
$templateCache.put('directives/formly-form.html', '<form class=formly role=form><formly-field ng-repeat="field in fields" options=field form-value=result[field.key||$index] class=formly-field form-id=options.uniqueFormId index=$index ng-hide=field.hide></formly-field><button type=submit class="btn btn-primary" ng-hide=options.hideSubmit>{{options.submitCopy || "Submit"}}</button></form>');

dist/formly.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)