We have multiple pages in a web application.I am using spring framework with java and angularjs ..I am not able to understand how to navigate from one page to another without calling the controller each time..Can anyone help?
Asked
Active
Viewed 380 times
-1
-
That's the whole purpose of the controller. why would you want that? – ChrisThompson Aug 08 '17 at 12:17
-
You should deal with static content: https://stackoverflow.com/questions/1483063/how-to-handle-static-content-in-spring-mvc – Optio Aug 08 '17 at 16:05
-
I am including js file (containing controller implementation stuff) in html file using script tag ...it isnt working ..i dont understand why...i went through the article above for including static resources but didnt work for me... – Hitasha Singh Aug 09 '17 at 12:59
1 Answers
0
// Code goes here
Below code may help you to redirect you from one page to another page.
(function () {
'use strict';
function LoginController($scope, $log, $location, $http) {
//onSuccess callback....
function onLoginSuccess(res) {
$log.info('Successfully logged in.');
$location.path(NavigationPath.HOME);
}
//onError callback
function onError(error) {
$log.error('Login in failed.', error);
}
/**
* Sign in user after validating the credentials.
*/
$scope.signIn = function () {
$scope.isSigningIn = true;
var formData = {
username: $scope.userName,
password: $scope.password
};
$http.post(formData).then(onLoginSuccess, onError).finally(function () {
//final stuff you can do here
});
};
onLoad();
}
var app = angular.module('app'),
requires = [
'$scope',
'$log',
'$location',
'$http',
LoginController
];
app.controller('LoginController', requires);
}());

Manish Joshi
- 93
- 13
-
I am separating the code in two parts such that all the controller stuff is inside js file and then including this js file in the html file using the script tag...but it doesnt seems to be working – Hitasha Singh Aug 09 '17 at 12:56