我控制器
App.controller('Ctrl', ['$scope', function ($scope) {
$scope.user = {};
$scope.view = function() {
console.log($scope.user);
console.log($scope.user.length);
}]);
我的HTML
<input type="text" ng-model="user.lastname" />
<input type="email" ng-model="user.email" />
<input type="text" ng-model="user.address" />
<input type="email" ng-model="user.id" />
<input type="text" ng-model="user.city" />
<input type="email" ng-model="user.country" /> ---> This will be a select
任何字段是强制性的,我所要做的基于用户输入的搜索功能。我必须验证用户必须提供至少一个数据的一件事。当我把控制台如上所述,我可以看到第一个值,而.length控制台返回未定义。