I have separate modules for my login page, which uses the loginApp module, and my home page, which utilizes the myApp module. Upon submitting on the login page, I aim to direct users to home.html.
Within my index.html (login page), the script is as follows:
<script>
angular.module("whole", ["loginApp", "myApp"]);
</script>
The following declaration is made at the top:
<html ng-app="whole" class="ng-scope">
However, I am encountering an issue with ngRoute. The configuration in my loginApp module looks like this:
"use strict";
var lapp = angular.module("loginApp", ["ngRoute", "ngCookies"]);
lapp.config(["$routeProvider", function ($routeProvider) {
$routeProvider
.when("/", {
templateUrl: "index.html"
})
.when("/home", {
templateUrl: "home.html"
})
.otherwise({redirectTo: '/'});
}]);
In my loginCtrl, I have the following code:
$scope.login = function () {
var credentials = {
username: $scope.username,
password: $scope.password
};
Auth.login(credentials, function (res) {
init();
$location.path("views/home.html");
}, function (err) {
init();
});
Furthermore, here's a snippet from my html file:
<div ng-controller="loginCtrl" class="login">
<form ng-submit="login()" method="post" name="form" novalidate>
<!--two inputs and stuff-->
<input type="submit" value="Login">
<!--Then some closing tags, whatever-->
Initially, the URL is:
http://localhost:8000/public_html/
After clicking submit (to login), the URL changes to:
http://localhost:8000/public_html/views/home.html#/basic
However, the view does not change unless I refresh the page. Despite ensuring that the "templateUrl" is correctly set, I cannot pinpoint the cause of this bug. It seems to be related to ngRoute.