私のリストがサービス中の配列リストに新しいオブジェクトをプッシュするには?angularjs - (サービス内の)私のリストに新しいオブジェクトを(スコープとして)プッシュ
私のコントローラには、私のリストにオブジェクトの新しいレイヤをプッシュする機能がありますが、リストの配列をサービスとして新しいファイルに移動してからです。それはもう働きません。
コントローラー:
$scope.addContact = function() {
$scope.person.contact.push({
contactType: "",
contactNumber: ""
});
};
サービス:私は "addContact" それは私のリストに新しいオブジェクトを ".push" になる
angular
.module("person")
.service("InitService", initializeItem);
function initializeItem() {
var self = this;
self.ReturnInit = function() {
var person = {
firstname: "",
lastname: "",
address: [
{
addresstype: "",
addresslocation: ""
}
],
contact: [
{
contacttype: "",
contactnumber: ""
}
]
};
return person;
};
};
毎回。
この探している:
person = {
firstname: "",
lastname: "",
address: [
{
addresstype: "",
addresslocation: ""
},{
addresstype: "",
addresslocation: ""
}
],
contact: [
{
contacttype: "",
contactnumber: ""
}
]