2

I am looking for solution for a problem which might not exist the way I am trying to do it. So if anyone can help me with the best way of doing this.

ISSUE:

I have the following input field:

 <input type="text" placeholder="quote" ng-model="person.quotes.quote">
 <input type="text" placeholder="author" ng-model="person.author">
 <input type="text" placeholder="category" ng-model="person.category">

And I have the following object:

$scope.person = {
author: $scope.author,
category: $scope.category,
quotes: [{quote: $scope.quote}]
};

I am trying to get the value person.quote into the array of quotes. But I can't seem to do it.

REASON:

The reason why I am doing this is that when a user fills the input fields and clicks on a button the values are saved into the $scope.person object. And that I push that entire object to my firebase API. I want to maintain the structure of my $scope.person object as I have described in my javascript the same in my firebase API. I can easily push author and category but the nested quotes objects are not being pushed.

THE ERROR I GET:

Error: Firebase.set failed: First argument contains undefined in property 'quotes.0.quote'

Thanks in advance and if this information is not enough please let me know so i can provide with more information.

1 Answer 1

5

the property quotes from object person is array.

ng-model="person.quotes[0].quote"
Sign up to request clarification or add additional context in comments.

1 Comment

Ah! so simple. I knew it was something small. Thank you so much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.