admin管理员组文章数量:1426056
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.
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.
Share Improve this question asked Nov 27, 2014 at 21:43 SkywalkerSkywalker 5,20417 gold badges66 silver badges127 bronze badges1 Answer
Reset to default 5the property quotes
from object person
is array.
ng-model="person.quotes[0].quote"
本文标签: javascriptNested objects and ngmodels in AngularJSStack Overflow
版权声明:本文标题:javascript - Nested objects and ng-models in Angular-JS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745459714a2659266.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论