简体   繁体   中英

SyntaxError: expected expression, got '<' on AngularJS route refresh

I am getting a

SyntaxError: expected expression, got '<'
when I refresh my AngularJS route with a URL parameter on the url. This happens when in HTML5 mode and the # is removed. I have routing for this in my .htaccess file to allow me to access any URL and have it routed to index.html. The error only occurs when I have a parameter on the end, for example:

\n.state('app.test', { \n                url: "/service/:test", \n                templateUrl: '/views/service.html' \n            }) \n

Going to /service/sampleText would result in the syntax error from above.

Thank you in advance for any assistance you can offer!

I thought I'd put my solution to this issue up here, since it took me a bit of finagling to find.

I was able to move my script include line for my app.js file, which includes my routing $stateProvider, to the body tag from the head tag of my index.html file and that fixed it for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM