首页 > TypeError: Cannot read property '$dirty' of undefined

TypeError: Cannot read property '$dirty' of undefined

ui-router用go跳转时有时会在控制台打印以下错误

    angular.js:13424 TypeError: Cannot read property '$dirty' of undefined
    at m.$scope.canNext (app.js:247)
    at fn0 (eval at <anonymous> (angular.js:14268), <anonymous>:4:428)
    at angular.js:15321
    at m.$digest (angular.js:16860)
    at angular.js:17064
    at e (angular.js:5824)
    at angular.js:6100

$scope.canNext的代码只有一行

return $scope.表单的名字.$dirty && $scope.表单的名字.$valid;

在html中是这样写的:

<form name="表单的名字">
<!-- //ETC-->
<input type="submit" ng-disabled="!canNext()" />
</form>

$scope.表单的名字 这个东西在controller中是undefined。 这个方法不能这么用,应该是页面里用 表单的名字.$dirty


<form name="表单的名字">
<!-- //ETC-->

<input type="submit" ng-disabled="表单的名字.$dirty&&表单的名字.$valid" />

</form>

【热门文章】
【热门文章】