I'm struggling to understand why the compare function and insert function in my code aren't functioning correctly. I suspect that one reason for this could be that the function is not being called by the button. How can I confirm this? It seems like alerts are not working in my Angular code.
This is the content of my loginHandler.js file:
(function() {
var app = angular.module('loginHandler', []);
app.controller('LoginController', ['$http' ,function($http){
var database = this;
this.validated = false;
database.dbData = [];
$http.get('/resources/DatabaseObject.json').success(function(data){
database.dbData = data;
});
this.login = function(credentials){
loggedInUser = credentals.username;
validated = true;
$http.get('/resources/DatabaseObject.json').success(function(data){
$scope.dbData.push({"123":{"username":"meph","ip":"123","timeLastLogin":"123"}}, "session");
});
};
this.checkSession = function(){
var ip = "123456";
if(session.ip.equals(123456)){
return true;
}
};
}]);
})();
Both the login and checkSession functions are not working as expected.
This is the content of the DatabaseObject.json file:
[{
"users": {
"cra": {
"firstName": "Jn",
"lastName": "it",
"username": "dmph",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="374556590106774e565f58581954585a">[email protected]</a>",
"ip": "192.168.1.1",
"password": "1234",
"computerName": "os",
"prviateKey": "1D3RW12390ASLEWRQ1235"
},
"mus": {
"firstName": "James",
"lastName": "mh",
"username": "ch",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b5df8384f5d2d8d4dcd99bd6dad8">[email protected]</a>",
"ip": "192.168.1.1",
"password": "11212",
"computerName": "ops",
"prviateKey": "1D3RW12390ASLEWRQ1235"
}
},
"session": {
"123456": {
"username": "crh",
"ip": "123456",
"timeLastLogin": "123456787654"
}
}
}]
Here is the relevant HTML code:
<html lang="en" ng-app="gemStore">
<!-- Add your unique and relevant HTML content here -->
</body>
</html>
I am unsure about the functionality of the submit button. Could someone please review my code and offer assistance? I have been attempting various solutions without success.