Javascript 在AngularJS中将元素添加到数组时,fnPtr不是一个函数
我有这个麻烦 我有一个复选框,当复选框被选中时,我想将3个对象加载到一个数组中,但当它发生时,我看到这个错误发生了六次: 错误:fnPtr不是一个函数Javascript 在AngularJS中将元素添加到数组时,fnPtr不是一个函数,javascript,angularjs,prototype,Javascript,Angularjs,Prototype,我有这个麻烦 我有一个复选框,当复选框被选中时,我想将3个对象加载到一个数组中,但当它发生时,我看到这个错误发生了六次: 错误:fnPtr不是一个函数 Parser.prototype.functionCall/is$scope.marriage.children可以直接使用,或者在通过setSons设置之前它不存在?如果看不到上下文源代码,也很难找到。我编辑了添加控制器代码的问题我也有同样的问题,除了错误have OPERATORS[“&&&]”是$scope.marriage.childre
Parser.prototype.functionCall/is
$scope.marriage.children
可以直接使用,或者在通过setSons
设置之前它不存在?如果看不到上下文源代码,也很难找到。我编辑了添加控制器代码的问题我也有同样的问题,除了错误have OPERATORS[“&&&]”是$scope.marriage.children
可直接使用,或者它在设置子
之前不存在?如果看不到上下文源代码,也很难找到。我编辑了问题,添加了控制器代码。我也有同样的问题,除了错误have OPERATORS[“&&”]
<div class="form-group col-sm-12 subject-field">
<label>Has children?</label>
<input type="checkbox" ng-model="marriage.has_children" ng-change="setSons()" title="If had children check the box">
</div>
<div class="col-sm-12 col-md-12" ng-repeat="littleBoy in marriage.children">
<h3>{{$index+1}}</h3>
...
</div>
angular.module('DExpress').controller('FormController',['$scope',
'$filter',
'$http', '$log',
function($scope,
$filter,
$http, $log)
{
$scope.marriage = {
lives_togheter: false,
has_children: false,
celebration_date: $filter('date')(new Date(), 'dd-MM-yyyy'),
separation_time: 0,
another_information: "",
state: "Montevideo",
city: "Montevideo",
country: "Uruguay",
children: []
};
$scope.addSon = function(){
var person = {
name: "",
surname: "",
birth_date: $scope.today,
studies: false,
where_studies: "School...",
year_of_study: "1st Grade",
is_disabled: false,
explanation: ""
};
$scope.marriage.children.push(person);
};
$scope.setSons = function(){
if($scope.marriage.has_children){
$scope.marriage.children=[];
$scope.addSon();
$scope.addSon();
}else{
$scope.marriage.children = [];
}
};
}