Angularjs 使用ionic ng模型返回TypeError:无法读取属性';用户名';未定义的
TypeError:无法读取未定义的属性“username”Angularjs 使用ionic ng模型返回TypeError:无法读取属性';用户名';未定义的,angularjs,ionic-framework,Angularjs,Ionic Framework,TypeError:无法读取未定义的属性“username” 在Scope.$Scope.login传递参数时出错。请将其更改为 ng-click=login(data.username,data.password) 然后,在控制器中 $scope.login = function(username,password){ $scope.username = username; $scope.password = password; ........... } 在控制器的第一行创建
在Scope.$Scope.login传递参数时出错。请将其更改为
ng-click=login(data.username,data.password)
然后,在控制器中
$scope.login = function(username,password){
$scope.username = username;
$scope.password = password;
...........
}
在控制器的第一行创建一个示例plnkrWrite
$scope.data={};
,然后重试。我是这样尝试的:$scope.data={};alert($scope.data.username);但仍然不起作用:[alert:undefined]fix:$scope.data={};alert(data.username);我非常相信它确实有效。我想了很多!