Angularjs TypeError:无法读取属性'';对于未定义的“从输入获取值”,使用角度js打印div中的值

Angularjs TypeError:无法读取属性'';对于未定义的“从输入获取值”,使用角度js打印div中的值,angularjs,Angularjs,HTML代码 上面是我正在构建的用于创建任务的应用程序的代码。当我尝试从输入中获取值使用angular js打印div中的值时,我得到以下错误:TypeError:无法读取未定义的属性“descripe”在开始将项推送到数组上之前初始化数组和$scope.data变量 $scope.toDoListItems = []; //in the beginning of your controller $scope.data = {}; //initialize your data object

HTML代码


上面是我正在构建的用于创建任务的应用程序的代码。当我尝试从输入中获取值使用angular js打印div中的值时,我得到以下错误:TypeError:无法读取未定义的属性“descripe”

在开始将项推送到数组上之前初始化数组和$scope.data变量

$scope.toDoListItems = []; //in the beginning of your controller
$scope.data = {}; //initialize your data object
将单击事件更新为

<button class="button button-block button-balanced" type="submit" ng-click="AddItem()">

至于我的show()函数,它仍然没有从div中的输入字段打印结果,我看不出调用show函数是从哪里来的?编辑您的代码以包含所需信息它是否解决了您最初发布的问题,对吗?是的,app.js文件中的show函数是编写的。显示为ng click=“check()”的按钮改为ng click=“show()”,我的输入字段是ng Modal=“searchText”,这对我来说是另一个问题,因为我仍然看不到您的更改。您必须验证是否正在调用show函数,只需为测试发出警报即可
$scope.toDoListItems = []; //in the beginning of your controller
$scope.data = {}; //initialize your data object
<button class="button button-block button-balanced" type="submit" ng-click="AddItem()">
$scope.AddItem = function () {
    $scope.toDoListItems.push({ task: $scope.data.describe,status: 'not done' });
    //reset the data variable after insert

    $scope.data = {};
}