1
votes

I'm trying to run Angular2 alpha 35

I have a server setup with a static shelf server. It works fine for publishing to heroku after pub build.

When i use pub serve to test locally, i don't seem to have control over routing, and i need more granular control to modify the routes to always point to index.html - (client side routing)

When i use shelf to point to the web folder - i can serve the asset - but i lose all of my dart transformers.

Question:

What is the best approach to serve a SPA for a native Dart project with client side routing?

1

1 Answers

1
votes

You don't need to use Dart Shelf to test Angular2 Locally. Pub Serve will work, while reserving Dart Shelf for production use.

Primarily, this turned out to be an issue with the WebStorm proxy server for pub. It was hitting the WebStorm proxy server and not finding the proper angular2 routes.

Running pub serve from the command line works flawlessly. To launch this directly from WebStorm make sure to create a custom debug configuration under 'Run' -> 'Edit Configurations' - otherwise:

  1. Start pub server from command line:

    pub serve

  2. in main declare the following:

    bootstrap(MySuperCoolApp, [ routerInjectables, // The base path of your application bind(APP_BASE_HREF).toValue('/'), bind(LocationStrategy).toClass(HashLocationStrategy) ]);

Then navigate Dartium to:

http://localhost:8080/#/your/custom/route/