我需要检查表单在控制器中是否有效。
视图:
<form novalidate="" name="createBusinessForm" ng-submit="setBusinessInformation()" class="css-form"> <!-- fields --> </form>
在我的控制器中:
.controller( 'BusinessCtrl', function ($scope, $http, $location, Business, BusinessService, UserService, Photo) { if ($scope.createBusinessForm.$valid) { $scope.informationStatus = true; } ...
我收到此错误:
TypeError: Cannot read property '$valid' of undefined
我已将控制器更新为:
.controller('BusinessCtrl', function ($scope, $http, $location, Business, BusinessService, UserService, Photo) { $scope.$watch('createBusinessForm.$valid', function(newVal) { //$scope.valid = newVal; $scope.informationStatus = true; }); ...