2017-10-14 153 views

回答

1

希望你可以试试这个:

使用Cloud Firestore SDK

let docRef = db.collection("following").doc("your-id"); 

docRef.get().then((doc)=> { 
    if (doc.exists) { 
     console.log("Document data:", doc.data()); 
     let myData=doc.data(); 
     let isTrue= myData.boolean-property-name;//return true or false 
     } else { 
     console.log("No such document!"); 
    } 
}).catch(function(error) { 
    console.log("Error getting document:", error); 
}); 

使用AngularFire2:Docs

注:

阅读这篇文章:Google Cloud Firestore integration with Ionic and AngularFire

your-id - 你需要通过你的doc这里

boolean-property-name - 这只是一个虚拟的名字。你需要在这里传递你的实际属性名称。在你的情况下,它就像cug.....

+0

你好,非常感谢你的答案...我试着用指示的代码,但它返回了3个错误,打印在链接:(https://drive.google。 com/open?id = 0B14jg18TLF3USC1xc292S3FYR0k) –

+0

查看更新。 – Sampath

+0

我现在所做的更改我只拿到1个错误: **打字稿错误 属性“GET”的类型不存在“AngularFirestoreDocument <{}>” ** –