![](/img/trans.png)
[英]What is the proper way to use transactions in firebase with Angular
[英]What's the right way to use the new firebase with an angular 2 project?
這兩個項目目前還很新。 我真的無法弄清楚在angular 2項目中使用firebase(較新版本)的正確方法是什么。
假設這是我的angular 2應用程序的主要index.html:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>NewApp</title>
<base href="/">
{{#unless environment.production}}
<script src="/ember-cli-live-reload.js" type="text/javascript"></script>
{{/unless}}
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<new-app-app>Loading...</new-app-app>
{{#each scripts.polyfills}}<script src="{{.}}"></script>{{/each}}
<script>
System.import('system-config.js').then(function () {
System.import('main');
}).catch(console.error.bind(console));
</script>
</body>
</html>
我在哪里放置配置字符串? 我的意思是這個:
<script src="https://www.gstatic.com/firebasejs/live/3.0/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "",
authDomain: "",
databaseURL: "",
storageBucket: "",
};
firebase.initializeApp(config);
</script>
以及如何在角度組件中訪問firebase對象? 最好的方法是什么?
我將使用Angularfire2將Firebase用於Angular2應用程序。
這樣,您可以在引導應用程序時對其進行配置:
import { FIREBASE_PROVIDERS, defaultFirebase } from 'angularfire2';
bootstrap(<MyApp>, [
FIREBASE_PROVIDERS,
defaultFirebase('https://<your-firebase-app>.firebaseio.com')
]);
有關庫配置的更多詳細信息,可以查看以下鏈接:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.