I'm having this trouble.
I have a checkbox, when the checkbox is checked I want to load 3 objects into an array, but when it happens I see this error that occurs six times:
Error: fnPtr is not a function Parser.prototype.functionCall/<@http://localhost:8383/MyApp/js/angular.js:10568:15 OPERATORS["==="].... Error: fnPtr is not a function Parser.prototype.functionCall/<@http://localhost:8383/MyApp/js/angular.js:10568:15 OPERATORS[">"]....
What I'm doing wrong?
This is my code:
Html:
<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>
Controller:
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 = [];
}
};
}
$scope.marriage.childrenavailable straight away or it doesn't exist until it is set bysetSons?