Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在AngularJS中将元素添加到数组时,fnPtr不是一个函数_Javascript_Angularjs_Prototype - Fatal编程技术网

Javascript 在AngularJS中将元素添加到数组时,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

我有这个麻烦

我有一个复选框,当复选框被选中时,我想将3个对象加载到一个数组中,但当它发生时,我看到这个错误发生了六次:

错误:fnPtr不是一个函数
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 = [];
                 }        
        };


    }