diff --git a/src/ng/directive/form.js b/src/ng/directive/form.js index d88b02c5508f..3c3fe3fdd07c 100644 --- a/src/ng/directive/form.js +++ b/src/ng/directive/form.js @@ -65,6 +65,8 @@ function FormController(element, attrs, $scope, $animate, $interpolate) { var form = this, controls = []; + var topLevel = $scope.$eval(attrs.ngFormTopLevel) || false; + // init state form.$error = {}; form.$$success = {}; @@ -76,6 +78,7 @@ function FormController(element, attrs, $scope, $animate, $interpolate) { form.$invalid = false; form.$submitted = false; form.$$parentForm = nullFormCtrl; + form.$$topLevel = topLevel; /** * @ngdoc method @@ -318,6 +321,9 @@ function FormController(element, attrs, $scope, $animate, $interpolate) { * * @param {string=} ngForm|name Name of the form. If specified, the form controller will be published into * related scope, under this name. + * @param {boolean} ngFormTopLevel Value which indicates that the form should be considered as a top level + * and that it should not propagate its state to its parent form (if there is one). By default, + * child forms propagate their state ($dirty, $pristine, $valid, ...) to its parent form. * */ @@ -416,6 +422,10 @@ function FormController(element, attrs, $scope, $animate, $interpolate) { angular.module('formExample', []) .controller('FormController', ['$scope', function($scope) { $scope.userType = 'guest'; + $scope.submitted = false; + $scope.submit = function (){ + $scope.submitted = true; + } }]);