Angular 2 app not working on server (works locally)

1,483 views
Skip to first unread message

HisDivineShadow

unread,
Jun 28, 2016, 5:41:36 PM6/28/16
to AngularJS
I don't understand this one.  I have an app when I load it from my local IIS it runs fine (in Chrome only).  When I load the same app from a remote server it doesn't run the OnInit of any of my views until a click on some active element on the page (like a form control or a menu link).  I have ngOnInit handlers on a few pages that I put break points in (using Chrome developer tools) and that's how I see the init being run only after some action on one of my elements.  The only error I see in the console is that it can't load one of the font definition files.  The file exists but it can't load it.




I don't see how this would cause the problem I'm having.  Again, the problem is that it doesn't Init any of my views.  What difference does it make that it's loading the app from my local machine or server (and why can't it load the font definition file)?  On occasion there is another font definition file that won't load but unlike the one above it's a failure in the platform-browser.umd.js.  


Long Field

unread,
Jun 28, 2016, 8:11:14 PM6/28/16
to AngularJS
Too many issues can cause this problem, like does user has permission for this file?

HisDivineShadow

unread,
Jun 29, 2016, 11:09:53 AM6/29/16
to AngularJS
I've resolved the loading of the WOFF2 file problem but the main problems still remains that the app doesn't seem to fie the OnInit event when the view loads.  Now there are no errors in the console nor are there any file load issues listed in the Network tab of the developer tools.  So, what could cause the OnInit event to not fire until I've clicked on something?  I can't see why this would be related to where the files were served from.  Once the browser has the files and had loaded the app it should run the same way.

HisDivineShadow

unread,
Jun 29, 2016, 11:53:13 AM6/29/16
to AngularJS
Good/Bad news, it started doing the same thing when running from my local server.  I made a couple minor changes in my authentication service class and now it doesn't work locally.  

Lucas Lacroix

unread,
Jun 29, 2016, 12:10:30 PM6/29/16
to AngularJS

I've never had the ngOnInit callback experience this issue. Can you reproduce in plunkr?


On Wed, Jun 29, 2016, 11:53 HisDivineShadow <buddy.ac...@gmail.com> wrote:
Good/Bad news, it started doing the same thing when running from my local server.  I made a couple minor changes in my authentication service class and now it doesn't work locally.  

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

HisDivineShadow

unread,
Jun 29, 2016, 12:42:46 PM6/29/16
to AngularJS
I've fixed the issue with it no calling OnInit.  While trying to fix problems with running older versions on Internet Explorer (v9 and v10) I found some info that I needed to add a couple of shims to my startup.  So, I had added the below scripts


"/node_modules/systemjs/dist/system-polyfills.js",
"/node_modules/angular2/es6/dev/src/testing/shims_for_IE.js",

These were apparently causing the failure to run OnInit.  I removed them and it works in Chrome, Edges and IE 11 again (but lots of problems with IE < v11).


Reply all
Reply to author
Forward
0 new messages