Angularfire2 seems to not load in ionic2
2.0.0-beta.6-preview
Angular: 2.2.1 Firebase: 3.6.1 AngularFire: 2.0.0-beta.6-preview Other (e.g. Ionic/Cordova, Node, browser, operating system): Cordova CLI: 6.4.0 Ionic Framework Version: 2.0.0-rc.3 Ionic CLI Version: 2.1.12 Ionic App Lib Version: 2.1.7 Ionic App Scripts Version: 0.0.44 ios-deploy version: 1.9.0 ios-sim version: 5.0.11 OS: macOS Sierra Node Version: v6.9.1 Xcode version: Xcode 8.1 Build version 8B62
How to reproduce these conditions
I'm trying to run angularfire after having the plain firebase library working (used only for login so far). I'm using ionic and ionic serve is not working. I'm getting this during ionic serve:
[19:04:51] ionic-app-scripts 0.0.44 [19:04:51] watch started ... [19:04:51] build dev started ... [19:04:51] clean started ... [19:04:51] clean finished in 4 ms [19:04:51] copy started ... [19:04:51] transpile started ... [19:04:55] build dev failed: Cannot read property 'indexOf' of undefined [19:04:55] copy finished in 3.41 s [19:04:55] watch ready in 3.43 s [19:04:55] dev server running: http://localhost:8100/
In the www/build folder the html and the js file are not there so the build is not completing.
Debug output
** Errors in the JavaScript console **
http://localhost:8100/build/main.css Failed to load resource: the server responded with a status of 404 (Not Found) (2) http://localhost:8100/build/main.js Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8100/build/main.css Failed to load resource: the server responded with a status of 404 (Not Found)
Expected behavior
Site loads
Actual behavior
Site does not load because of missing js and html files when angular fire is just imported
Sorry @ix-xerri . Without looking at the repo, I may not be able to add more. Hopefully someone else. I'll wait for @Demi-ob to share his repo and see if I can reproduce the issue. The only difference I can see in package.json is the version number of zone.js.
"zone.js": "0.6.21" vs "zone.js": "0.6.26"
I am not sure if that is a problem, but you can give it a try.
I updated zone.js to 0.6.26 but no luck
You can try to use Firebase 3.3.0. Thats the version angularfire2 uses. Maybe there is a conflict when you try to use two different versions in the same class.
it works! need to go into detail and use angular fire but the build finishes and the site loads no problem.
Hurray!!!. It works. Thanks a lot @ix-xerri, @mukesh54 and @Chris1308
Glad you were able to resolve this. In the future, please follow the issue template and submit a working repro of the issue from the start, and it won't require so much dev time to get to the solution.
@ix-xerri Sorry if I missed it, but what did you do to get this to work? you added Firebase to your package.json in addition to the angularFire package?
You need Firebase 3.3.0 and the latest angularfire
@ix-xerri Thanks got it. I had removed node_modules multiple times. NPM clear cache and correct fresh package.json must have done the trick finally...
In my package.json, i do have firebase version
"firebase": "^3.6.1",
and it works fine for me. I've my repo here.
I've got node version as v6.9.1 npm version as 3.10.8 cordova version as 6.4.0 and ionic version as 2.1.8
@mukesh51 interesting. I wonder if you were to upgrade your ionic-cli to 2.1.12 if you would have the same error we were experiencing. I will try the ^3.6.1 of firebase repo and see if I can still reproduce the issue.
when I am retrieving data from firebase it show URL like http://localhost:4200/listing/-Kdl_wRRkn7nJxgz4B54 but on referencing it show URL like http://localhost:4200/ it remove id from URL