Issue
I want to popup an alert message from an angularJS function, but it's not working.
Script
app.controller("APIController", function ($scope, $http) {
$scope.saveSubs = function () {
var sub = {
UserName: $scope.username,
Password: $scope.password
};
if ($scope.username === 'admin' && $scope.password === 'admin') {
window.location.href = '/Home/HotelSearchRedirect';
} else {
$window.alert("User name or password wrong. please enter correct username or password.");
}
};});
What is wrong with this code?
Solution
$window
needs to be injected.
app.controller("APIController", function ($scope, $http,$window) {
$scope.saveSubs = function () {
var sub = {
UserName: $scope.username,
Password: $scope.password
};
if ($scope.username === 'admin' && $scope.password === 'admin') {
window.location.href = '/Home/HotelSearchRedirect';
} else {
$window.alert("User name or password wrong. please enter correct username or password.");
}
};});
Just replace this code.
Answered By - Narendra Solanki
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.