Dima Vleskov Dima Vleskov - 1 year ago 65
AngularJS Question

angular.js Routing doesn't work on the server

I'm using ngRoute in my site, it work well on my computer (local) but on the server routing doesn't work. On my computer all my files are html, on the server i rename them as php. How can i fix it?

var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider, $compileProvider) {
.when("/", {
templateUrl : "pages/main.php",
controller: 'oneCtrl'
.when("/about", {
templateUrl : "pages/about.php"
.when("/news", {
templateUrl : "pages/news.php"

Answer Source

Based on the error messages you're getting (as you said in the comments), the Angular library is not being loaded. Double-check the URL. Also in the browser dev tools, check the Network tab and see what error it shows. Probably a 404 not found.

After checking your website and the line where you said the error was occurring (line 156 of route.js), change your code to this:

    $('.counter-one span').eq(0).html(value1 + ' ');
    $('.counter-two span').eq(0).html(value2 + ' ');

You did a search/replace for "html" to "php" but that also replaced the jQuery html() command. Just fix these two lines and you should be good.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download