Search code examples
javascriptangularjsangularjs-routing

NgRoute not working


For some reason im not sure about my ngRoute here is not working properly. Please help me thankyou. Here is my cloud9 file where you can see live preiview and edit code. And here is my script.js:

var app = angular.module('ChattApp', ["firebase", "ngRoute"])


app.config(["$routeProvider",  function($routeProvider){

  $routeProvider
    .when('/', {
      templateUrl: 'HtmlFiles/login.html',
      controller : 'LoginController.js'
    })

    .otherwise({
      redirectTo: '/'

    })
    //Talk In Chat/Group Chat. I have to go to school now..


}]
)

app.factory("Auth", ["$firebaseAuth",
  function($firebaseAuth) {
    var ref = new Firebase("https://uniquecoders.firebaseio.com/");
    return $firebaseAuth(ref);
  }
]);

Solution

  • Remove app definition in all controller files.. as app is already defined in another script.. the cause is that the variable is being redefined for each loaded controller file..

    please check http://www.w3schools.com/js/js_scope.asp for variable scope lifetimes