How can I set a form contained inside a ng-include to be prestine?

后端 未结 4 1096
轻奢々
轻奢々 2021-01-07 23:33

I have the following code:

4条回答
  •  终归单人心
    2021-01-07 23:54

    Well, one way to do it is to broadcast an event, like so:

    angular.module('myApp',[])
        .controller('AdminCtrl',function($scope){
            $scope.modalReset = function(){
                $scope.$broadcast('modal-reset');
            };
        })
        .controller('ModalCtrl', function($scope){
            $scope.$on('modal-reset', function(){
                $scope.itemForm.$setPristine();
            });
        });
    

    This way you don't have to traverse the dom.

提交回复
热议问题