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>
阅读 6.8k
2 个回答

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

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

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

</form>

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题