Skip to content

Commit 1963d2d

Browse files
katowulfdavideast
authored andcommitted
chore(docs): Update readme instructions (angular#506)
Include troubleshooting steps for "Cannot find namespace 'firebase'" Update versions and syntax to match latest angular-cli output.
1 parent be28495 commit 1963d2d

File tree

1 file changed

+60
-21
lines changed

1 file changed

+60
-21
lines changed

docs/1-install-and-setup.md

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
55
**The setups below use the Webpack branch of the [Angular CLI](https://github.com/angular/angular-cli).**
66

7-
**For the Broccoli/System.js branch [see this set up guide](broccoli-system-js-cli-setup.md)**
8-
97
### 0. Prerequisites
108

119
You need the Angular CLI, typings, and TypeScript 2.0. TypeScript 2.0 is required for AngularFire2.
@@ -16,9 +14,20 @@ npm install -g angular-cli@webpack
1614
npm install angular-cli@webpack --save-dev
1715
# make sure you have typings installed
1816
npm install -g typings
19-
npm install -g [email protected]
17+
npm install -g [email protected]
18+
```
19+
20+
Verify you have the correct version installed by running `ng -v` and ensuring that you see `angular-cli: 1.x.x-beta.x-webpack.x`. If not, you may need to do the following:
21+
22+
```bash
23+
# if you have the wrong cli version only
24+
npm uninstall -g angular-cli
25+
26+
# reinstall clean version
27+
npm install -g angular-cli@webpack
2028
```
2129

30+
2231
### 1. Create a new project
2332

2433
```bash
@@ -28,24 +37,32 @@ cd <project-name>
2837

2938
The Angular CLI's `new` command will set up the latest Angular build in a new project structure.
3039

31-
### 2. Install AngularFire 2 and Firebase
40+
### 2. Test your Setup
41+
42+
```bash
43+
ng serve
44+
open http://localhost:4200
45+
```
46+
47+
You should see a message that says *App works!*
48+
49+
### 3. Install AngularFire 2 and Firebase
3250

3351
```bash
3452
npm install angularfire2 firebase --save
3553
```
3654

3755
Now that you have a new project setup, install AngularFire 2 and Firebase from npm.
3856

39-
### 3. Setup @NgModule
57+
### 4. Setup @NgModule
4058

4159
Open `/src/app/app.module.ts`, inject the Firebase providers, and specify your Firebase configuration.
4260
This can be found in your project at [the Firebase Console](https://console.firebase.google.com):
4361

4462
```ts
4563
import { BrowserModule } from '@angular/platform-browser';
46-
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
47-
import { enableProdMode, NgModule } from '@angular/core';
48-
import { AppComponent, environment } from './app/';
64+
import { NgModule } from '@angular/core';
65+
import { AppComponent } from './app.component';
4966
import { AngularFireModule } from 'angularfire2';
5067

5168
// Must export the config
@@ -68,19 +85,19 @@ export class MyAppModule {}
6885

6986
```
7087

71-
### 4. Inject AngularFire
88+
### 5. Inject AngularFire
7289

73-
Open `/src/app/<my-app>.component.ts`, and make sure to modify/delete any tests to get the sample working (tests are still important, you know):
90+
Open `/src/app/app.component.ts`, and make sure to modify/delete any tests to get the sample working (tests are still important, you know):
7491

7592
```ts
7693
import { Component } from '@angular/core';
7794
import { AngularFire, FirebaseListObservable } from 'angularfire2';
7895

7996
@Component({
8097
moduleId: module.id,
81-
selector: '<my-app>-app',
82-
templateUrl: '<my-app>.component.html',
83-
styleUrls: ['<my-app>.component.css']
98+
selector: 'root-app',
99+
templateUrl: 'app.component.html',
100+
styleUrls: ['app.component.css']
84101
})
85102
export class <MyApp>Component {
86103
constructor(af: AngularFire) {
@@ -90,29 +107,29 @@ export class <MyApp>Component {
90107

91108
```
92109

93-
### 5. Bind to a list
110+
### 6. Bind to a list
94111

95-
In `/src/app/<my-app>.component.ts`:
112+
In `/src/app/app.component.ts`:
96113

97114
```ts
98115
import { Component } from '@angular/core';
99116
import { AngularFire, FirebaseListObservable } from 'angularfire2';
100117

101118
@Component({
102119
moduleId: module.id,
103-
selector: '<my-app>-app',
104-
templateUrl: '<my-app>.component.html',
105-
styleUrls: ['<my-app>.component.css']
120+
selector: 'root-app',
121+
templateUrl: 'app.component.html',
122+
styleUrls: ['app.component.css']
106123
})
107-
export class <MyApp>Component {
124+
export class AppComponent {
108125
items: FirebaseListObservable<any[]>;
109126
constructor(af: AngularFire) {
110127
this.items = af.database.list('items');
111128
}
112129
}
113130
```
114131

115-
Open `/src/app/<my-app>.component.html`:
132+
Open `/src/app/app.component.html`:
116133

117134
```html
118135
<ul>
@@ -122,7 +139,7 @@ Open `/src/app/<my-app>.component.html`:
122139
</ul>
123140
```
124141

125-
### 6. Serve
142+
### 6. Run your app
126143

127144
```bash
128145
ng serve
@@ -133,3 +150,25 @@ Run the serve command and go to `localhost:4200` in your browser.
133150
And that's it! If it totally borke, file an issue and let us know.
134151

135152
###[Next Step: Retrieving data as objects](2-retrieving-data-as-objects.md)
153+
154+
### Troubleshooting
155+
156+
#### Cannot find namespace 'firebase'.
157+
158+
If you run into this error while trying to invoke `ng serve`, open `src/tsconfig.json` and add the "types" array as follows:
159+
160+
```json
161+
{
162+
"compilerOptions": {
163+
...
164+
"typeRoots": [
165+
"../node_modules/@types"
166+
],
167+
168+
// ADD THIS
169+
"types": [
170+
"firebase"
171+
]
172+
}
173+
}
174+
```

0 commit comments

Comments
 (0)