I have a login page, and a home page and the way I am implementing them is that each has its own module. Login page has loginApp and home page has myApp. When I click the submit, I want to navigate to home.html.
In my index.html(login page), I have this:
<script>
angular.module("whole", ["loginApp", "myApp"]);
</script>
And at top I declared this:
<html ng-app="whole" class="ng-scope">
Now I am stuck at this ngRoute. I have 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: '/'});
}]);
and this in my loginCtrl:
$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();
});
and this in my html:
<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-->
My initial url is :
http://localhost:8000/public_html/
after I click submit(login), it changes to
http://localhost:8000/public_html/views/home.html#/basic
but then the view doesn't change unless I refresh the page. There was another post about this but he did a typo and I am sure I did type "templateUrl" correctly. I do not even have an idea about what might have caused this bug. I just assumed ngRoute.