I m new to angular and i'm trying to make a add character form field but i'm doing something wrong
Here is my html form with angular
<form class="add_character" ng-submit="characterController.addCharacter(characters)">
<input ng-model="addCharacterCtrl.character.name" type="text">
<input ng-model="addCharacterCtrl.character.last_name" type="text">
<input ng-model="addCharacterCtrl.character.age" type="text">
<textarea ng-model="addCharacterCtrl.character.history" name="" id="" cols="30" rows="10"></textarea>
<input type="submit">
</form>
And here is my controller with my add character function in it:
app.controller('CharacterController', function() {
this.characters = personages;
this.addCharacter = function(newCharacter){
addCharacter.push(this.characters);
this.addCharacter = [];
};
});
var personages = [
{
name: 'Character',
last_name: 'character',
age: 21,
history: 'character info',
},
{
name: 'Character2',
last_name: 'character',
age: 44,
history: 'character info',
}
];
And this is the error i get:
Blockquote angular.js:13920 TypeError: Cannot read property 'push' of undefined at Object.addCharacter (addCharacter.js:11) at fn (eval at compile (angular.js:14817), :4:394) at b (angular.js:15906) at e (angular.js:25885) at m.$eval (angular.js:17682) at m.$apply (angular.js:17782) at HTMLFormElement. (angular.js:25890) at Sf (angular.js:3497) at HTMLFormElement.d (angular.js:3485)
I hope someone can help me