Angular - blank page, how to diagnose bootstrapping issues? - angularjs

I have a working (in development) Angular app and I've just got my Grunt distribution script working how I want it to, however when run my app through Grunt and then run it from the distribution folder I just get a blank page, no errors, no logging in console, no missing files in the network tab in Chrome etc, it appears everything loads but nothing happens.
I've run into this issue before during development and thrashed around until it worked, however this is now much more complex due to the minified files in distribution etc.
I'd like to properly diagnose this blank page issue but I'm not sure where to start, it appears that Angular is simply not bootstrapping at all after processing to dist mode.
It appears there is no such thing as a very verbose diagnostic mode for Angular, I've switched to the uniminified and there is nothing reported at all.
I checked the minified html file and my ng-app tag is still there on the html element as it should be so that's not the issue.
Also if I drop to console I can type angular and get back the output for it, so it's there, just not doing anything.
Where to start?

Start with Chrome devtools open when you load the page.
Add $log.debug statements at the top of all your services and controllers.
app.js will not work without the
['paramname1', 'paramname2', function(paramname1, paramname2) {
version (all the other files minify fine with out it.)

Related

React App not loading, showing "Uncaught SyntaxError: Unexpected token '<'" in console, but works in Private Window

I have browsed many possible solutions to this error with no success. I understand the fundamental issue is that the request to /static/js/main.[hash].js is expecting JS, and instead is returning HTML. I can not, however, understand why the application runs fine while using a Private window, and also will work ONE time after clearing cache and hard reload. In addition to the error message, we get a white screen and the app does not load.
Looking at the Network tab in the browser, I compared the request when working and when not working. I noticed that when working, i.e. in private window, it seems as though the HTML is fetched using a different endpoint, /null. The response is the same HTML that causes the error (the app HTML), but for some reason it works here.
It seems as though the error could be fixed if I could define the request to accept HTML or JSX, but I don't know where to find where this request is called as it seems as though this is all handled by Webpack.
One thing to note, is that when running yarn build and serving the build locally, we still get the error message, but the app does load (no white screen). In the local build HTML, we find a script tag like this:
<script src="undefined"></script>
While the production (breaking) build gives us this:
<script type="text/javascript" src="/static/js/main.ff34f559.js"></script>
edit: The project was created using CRA then freshly ejected
Any help is greatly appreciated!

gulp files aren't refresh in browser

I have a problem with gulp file on my Backbone project. I'm working on a project with two other peoples. With them everything is working. I have a problem with browser cache - I think is with browser cache.
How it looks:
When I made changes gulp watch doesn't return any errors. Gulp copies all files from the src to dist folder. I've checked my files and they are saving correctly.
I turned off browser cache in the developer toolbar and it won't help. Sometimes I need to wait few minutes before I see my changes, and sometimes I need to refresh 20-30 times to see changes I've made.
Many time I see in console this error:
router.js:22 Uncaught SyntaxError: Unexpected end of input
When I debug this file I see that this file is incomplete but when open this file in browser directly - it is complete but still console shows an error
What else can I do, because I can't work like this?

AngularJS blank page on Safari iOS but runs fine everywhere else

I wrote a small AngularJS app that seems to run fine everywhere except in Safari (iOS) where I only see a blank page. If I hook up the phone to my mac and run Web Inspector I can see that there are no javascript errors (in fact the app runs fine and by looking at the DOM I see that scope variables are properly evaluated and replaced in the templates). What I DO see are many CSS errors. If I remove the offending CSS styles (Bootstrap 3) the errors go away yet the page remains blank. I tried removing all CSS and most trivial JS libs to no avail.
I'm using the following JS/CSS (in order of appearance on index.html):
bootstrap.min.css (v3.3.6)
bootstrap-theme.min.css (v3.3.6)
app.css (my own stylesheet which literally has two trivial style definitions)
angular.js (v1.4.9)
angular-route.js (v1.4.9)
ui-bootstrap.js (v1.1.2)
ui-bootstrap-tpls.js (v1.1.2)
lodash.js (v4.5.0)
moment.js (v2.11.2)
app.js (my own app)
Backend: Node 0.10 (running on a free OpenShift account) with Express v4. Files are served via the static middleware. No manual uploading is being done; deployment happens straight from the git repo after doing a push.
EDIT: Completely removed all CSS but problem persists. App fully works everywhere and still showing a blank screen on Safari iOS.

AngularJS not working on some browsers/devices

I'm using Angular on my site, but I've been having reports on it often not working. Often users have to try different browsers/devices to get it to work. On my computer it works fine on Chrome, Opera and Firefox, latest versions. I've had reports of the page not working for visitors when using Firefox (version 31.6.0) and Safari though.
I have a smartphone of brand Öwn (Chilean or Peruvian I think), and the angular code does not work on this phone. I've tried using Chrome and the Öwn browser (some browser of their own). I have expandable content powered by jQuery, and that works fine, so it's definitely only Angular the page has problems with.
I tried removing all dependencies (using ngAnimate and ui.bootstrap for datepicker, and ngDialog), but still doesn't work on my phone.
I'm sorry I don't have more details. This is the page where the problems happen:
https://www.easterisland.travel/tours/
Does anyone have a clue? Thank you!
The problem in the end was in the code of an Angular function. When declaring a new object, I hadn't applied a value to one of the variables. This:
var tourObj = {groupId: groupId, pricePP: pricePP, savingsPP};
should have been this:
var tourObj = {groupId: groupId, pricePP: pricePP, savingsPP: savingsPP};
It was tricky since some browsers accepted it (Chrome and later Firefox) but many didn't. To locate the problem I checked error console of Safari Mac, and all it said was that angular.min.js.map and angular-animate.min.js.map were missing. .map files are for showing debug messages with minified code. Once the .map files had been added (find .map files for angular here, clicking folder for your angular version), the error console showed me exact location of the error.

AngularJS loaded twice with Rails asset pipeline

I have set up rails to use bower according to the following guide: http://joelencioni.com/blog/2014/01/03/integrating-bower-with-rails/
I have installed AngularJS and included it in my application.js file.
Now, when I run rake assets:precompile, I get the following error in the console:
WARNING: Tried to load angular more than once.
But my application continues to (seemingly) work fine. When I run rake assets:clobber, I no longer get the error.
I read through the many StackOverflow questions and answers relating to this error and still couldn't find a solution. ng-app is only declared once, there are no errors with my templates and how I include them, turbolinks is removed, etc.
What could cause this error when I compile my assets?
UPDATE: Some strange behaviour here... running the app in production with Passenger, the above error doesn't show up.

Resources