0
我需要将2个空的person
对象添加到数组中并填充它之后。 Chrome抱怨TypeError: object is not a function at new <anonymous>
。怎么了?TypeError:对象不是新的函数<anonymous>
$scope.person = {
firstName : '',
lastName : '',
dateOfBirth : '',
sex : '',
nationality : ''
};
$scope.persons = [];
$scope.persons.push(new $scope.person); // error
$scope.persons.push(new $scope.person);
正是它所说的。 '$ scope.person'不是一个构造函数,所以你不能创建它的一个新实例。 – Quentin 2014-12-09 11:55:23
你似乎试图克隆该对象。作为副本结束。 – Quentin 2014-12-09 11:55:43