Why is ng-controller needed to publish FormController on scope?


#1

I’m creating my first Ionic application, and not seeing typical Angular behavior for FormController.

On the view, the form exists on the scope (e.g., I can display {{MyForm.$valid}} and watch it change. However, in the Controller method that is called on submit, $scope.MyForm is undefined.

This is the case whether I use the name or the ng-submit attributes.

I added ng-controller to an element around the , and now it works.

Anybody know what’s going on here?


#2

This was initially quite a struggle for me as well. What I do now is pass the form to the controller in the submit call.

<form name="greatForm" ng-submit="submit(greatForm">
$scope.submit(form) {
  if(form.$invalid) return;
}


#3

Thanks Justin, and hope all is well with KiT.

But do you understand WHY this is happening?

Is it a state thing? (this is my first UI Router app) Or is it a bug?