mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-17 03:01:06 +00:00
parent
47a2a9829f
commit
0fcd1e3b1f
2 changed files with 14 additions and 3 deletions
|
|
@ -23,7 +23,7 @@ var nullFormCtrl = {
|
||||||
*
|
*
|
||||||
* - keys are validation tokens (error names) — such as `required`, `url` or `email`),
|
* - keys are validation tokens (error names) — such as `required`, `url` or `email`),
|
||||||
* - values are arrays of controls or forms that are invalid with given error.
|
* - values are arrays of controls or forms that are invalid with given error.
|
||||||
*
|
*
|
||||||
* @description
|
* @description
|
||||||
* `FormController` keeps track of all its controls and nested forms as well as state of them,
|
* `FormController` keeps track of all its controls and nested forms as well as state of them,
|
||||||
* such as being valid/invalid or dirty/pristine.
|
* such as being valid/invalid or dirty/pristine.
|
||||||
|
|
@ -42,7 +42,7 @@ function FormController(element, attrs) {
|
||||||
controls = [];
|
controls = [];
|
||||||
|
|
||||||
// init state
|
// init state
|
||||||
form.$name = attrs.name;
|
form.$name = attrs.name || attrs.ngForm;
|
||||||
form.$dirty = false;
|
form.$dirty = false;
|
||||||
form.$pristine = true;
|
form.$pristine = true;
|
||||||
form.$valid = true;
|
form.$valid = true;
|
||||||
|
|
@ -108,7 +108,7 @@ function FormController(element, attrs) {
|
||||||
*
|
*
|
||||||
* @description
|
* @description
|
||||||
* Sets the validity of a form control.
|
* Sets the validity of a form control.
|
||||||
*
|
*
|
||||||
* This method will also propagate to parent forms.
|
* This method will also propagate to parent forms.
|
||||||
*/
|
*/
|
||||||
form.$setValidity = function(validationToken, isValid, control) {
|
form.$setValidity = function(validationToken, isValid, control) {
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,17 @@ describe('form', function() {
|
||||||
expect(scope.myForm.alias).toBeDefined();
|
expect(scope.myForm.alias).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should use ngForm value as form name when nested inside form', function () {
|
||||||
|
doc = $compile(
|
||||||
|
'<form name="myForm">' +
|
||||||
|
'<div ng-form="nestedForm"><input type="text" name="alias" ng-model="value"/></div>' +
|
||||||
|
'</form>')(scope);
|
||||||
|
|
||||||
|
expect(scope.myForm).toBeDefined();
|
||||||
|
expect(scope.myForm.nestedForm).toBeDefined();
|
||||||
|
expect(scope.myForm.nestedForm.alias).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should publish form to scope when name attr is defined', function() {
|
it('should publish form to scope when name attr is defined', function() {
|
||||||
doc = $compile('<form name="myForm"></form>')(scope);
|
doc = $compile('<form name="myForm"></form>')(scope);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue