Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Angular2 doesn't seem to be working client side when publishing with VS Code #338

Closed
levarcooper opened this issue Sep 28, 2016 · 8 comments

Comments

@levarcooper
Copy link

levarcooper commented Sep 28, 2016

I'm running the ANGULAR2SPA app in VS Code and everything seems to be working fine with the exception of the following:

  • Increment button is not working/ (click)="function()" is completely removed on page load
  • Pages are reloading when switching between views

When I run the application from VS 2015 Professional, everything works perfectly. I disabled javascript in my browser and it works exactly as it did with "dotnet run" and VS Code. I checked the browser to make sure vendor.js was loaded. Is there anything in VS Code that would prevent would prevent javascript from running? Obviously I'm just working from VS 2015 but I use VS Code when working on a Mac so I wanted to know if anyone else experienced similar issues.

@MarkPieszak
Copy link
Contributor

MarkPieszak commented Sep 28, 2016

I'm not sure what browser you are using, but it sounds like you have JavaScript Disabled.
Otherwise, VSCode might not be compiling the webpack files & such properly, it could be something in your Launch.json?

In Chrome go into settings and make sure this is Unchecked:

image

@levarcooper
Copy link
Author

Thanks for the quick reply, Mark. That's what I thought initially and that's why I tried disabling/enabling. I experienced this issue on both my Mac and PC when I cloned the repository. "dotnet run" from the command prompt/terminal gave me the same result. On the PC, I ran the same files in the same browser from Visual Studio 2015 with no problems. Not sure what could be the issue.

@SteveSandersonMS
Copy link
Member

In most cases, VS Code is just a text editor and doesn't influence how your application runs. If you've set up some custom launch.json then that might affect it, so if so, try removing that and just running directly from the command line.

If that's not it, I'd need more information (ideally, repro steps) otherwise I'm not sure how it would be possible to proceed with diagnosing this. Sorry!

@MarkPieszak
Copy link
Contributor

@levarcooper So potentially you might need to run webpack first (in command line), to build all the files, then do dotnet run I've had that happen to me before with projects & VSCode.
Are you running the base Repo here?

@MrCrimp
Copy link

MrCrimp commented Sep 28, 2016

For me it was due to the environment variable not being set to 'Development' and webpack-dev-server fails to serve the in-memory script files.

Set environment explicitly to Development
For osx in terminal run: ASPNETCORE_ENVIRONMENT=Development dotnet run

For VsCode try launching as sudo/administrator.

More info and options here #302

@MarkPieszak
Copy link
Contributor

I also think recent updates Steve made look they might make the default ENV Development, so things like this don't happen.

@levarcooper
Copy link
Author

@MarkPieszak That was the problem. I ran webpack and everything worked perfectly. Of course, I did everything but that which actually makes sense hindsight. Thank you both for your help with this.

@levarcooper levarcooper changed the title Angular2 doesn't seem to be working client side Angular2 doesn't seem to be working client side when publishing with VS Code Sep 29, 2016
@johnazre
Copy link

I downloaded it yesterday and I was having issues with that until I set the environment to development.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants