Giter Club home page Giter Club logo

Comments (7)

jacobmumm avatar jacobmumm commented on May 26, 2024

@Hoverbear Right now, if you're using yeoman server to launch this, the only way to have all your routes work and reloadable is to use the hash style href="/#/alt".

The angular generator leaves out $locationProvider.html5Mode(true); in the app.js file after configuring the routes. We can put this back in, but we would run into the issue you describe where you can navigate to the /alt link, but you can't reload it.

The problem is that the yeoman server doesn't have a default route which serves the index.html file. If that were the case, you could use the route /alt and serve the index file which would then load views/alt.html.

Theory is that the express server gets a request, if it's not a static file or api route, it should serve the index.html file. That way, you can load up any page in the app from a clean URL. The last line in my express servers is app.get("*", routes.index); It's a catch-all route when all static files and api routes have not matched.

from generator.

dhruv-bhatia avatar dhruv-bhatia commented on May 26, 2024

@jacobmumm Thanks for the info - I can confirm the same behaviour. I.e. routes load the Yeoman 404 page instead of the correct AngularJS route when using$locationProvider.html5Mode(true);.

@btford I guess a solution would be to get the aJS generator to just create a 404 route in app.js, and point all unknown URL's towards index.html?

from generator.

shairez avatar shairez commented on May 26, 2024

+1

from generator.

NathanWalker avatar NathanWalker commented on May 26, 2024

Screen Shot 2013-01-14 at 10 20 47 AM
What is the status on this [image attached]? Any workaround for this livereload issue?

  1. yeoman server should either allow configuration options to be passed in, or at least allow easy configuration of the server.
  2. yeoman's server configuration (when using angular and html5Mode=true) should provide a catch all to serve up index.html all the time to allow the angular app to handle the routing inside the app.

In meantime, would love if someone could point towards a temporary workaround to get this to work. Modify yeomans server configuration in the internals somewhere?

from generator.

NathanWalker avatar NathanWalker commented on May 26, 2024

Here is the temporary WORKAROUND:

Yeoman LiveReload configuration tweak

This is a temporary hack until yeoman's server configuration supports an option to do something like this

pico /usr/local/lib/node_modules/yeoman/tasks/server.js

Ctrl +W, search for: function errorHandler

Paste the below block in between the following:

return function errorHandler(req, res, next) {

fs.readFile('app/index.html',function (err, data){
    res.writeHead(200, {'Content-Type': 'text/html','Content-Length':data.length});
    res.write(data);
    res.end();
});
return;

// Figure out the requested path

Ctrl +O (that's the letter 'O') - to SAVE!

Now yeoman should play nice with LiveReload and change watching. No More 404 when LiveReload fires!!

from generator.

patcito avatar patcito commented on May 26, 2024

@NathanWalker your workaround doesn't work with beta3 (as yeoman is using grunt for server). Any idea how to do it with grunt?

from generator.

L42y avatar L42y commented on May 26, 2024

@patcito yeoman/generator-angular#132

from generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.