1
現在、私はhtmlで画像を受け取るようにハードコードされたURLの配列を持っています。Json Arrayにfirebaseレスポンスを格納する方法
$scope.product = {
"images" : [
{"image": "https://s3-us-west-2.amazonaws.com/s.cdpn.io/194929/colorburst-700x700.jpg"},
{"image": "https://s3-us-west-2.amazonaws.com/s.cdpn.io/194929/colorburst-700x700.jpg"},
{"image": "https://s3-us-west-2.amazonaws.com/s.cdpn.io/194929/colorburst-700x700.jpg"}
] };
私は、データベースからデータを受け取る方法について学習しましたが、私は、私は現在受け付けております「$のscope.product」
に示されているもののようなJSON配列に結果を保存しますか
// Get a reference to our posts
var ref = new Firebase("https://<database>.firebaseio.com/profile");
// Retrieve new posts as they are added to our database
ref.on("child_added", function(snapshot, prevChildKey) {
var newPost = snapshot.val();
debugger;
console.log("The email is: " + newPost.email);
});
ありがとうございました!構造は正しくなっていますが、どのようにしてこのオブジェクトにアクセスできますか? htmlページが読み込まれるまでにオブジェクトがまだヌルであるようです。私はHTMLでng-repeatを使用していますが、オブジェクトの人口が非常に遅くなっているようです。あなたは、オブジェクトが人口が投入されていることを確認する方法に関する提案を持っています – noobie212
@ noobie212私は本当に角度に慣れていませんが、それは[この回答]ように見える(http://stackoverflow.com/questions/15891052/dynamically-add-item -to-angularjs-ng-repeat)はあなたが望むものを持っているかもしれません。 – Ouroborus