in Education by
.controller('LoginCtrl', function($scope, $rootScope, $http, $state) { window.localStorage.removeItem("loggedIn"); if(window.localStorage.getItem("loggedIn") == undefined) { $scope.doLogin = function() { var username = $scope.fName + " " + $scope.lName; console.log(username); //store login information window.localStorage.setItem("username", username); window.localStorage.setItem("password", $scope.password); window.localStorage.setItem("loggedIn", true); $http.post('http://localhost:8000/login',{ userName: window.localStorage.getItem("username"), password: window.localStorage.getItem("password"), token: $rootScope.devToken, platform: ionic.Platform.platform() }); alert("Login Success"); $state.go('main'); }; } else { alert("Login Success"); $state.go('main'); } })
Run code snippetExpand snippet I am trying to get the text from the html field fName and lName using $scope.fName because fName is a ng-model. How come it is returning undefined? I have the controllers set properly. I just can't figure out why username is outputting undefined? I am trying to load the app up at login.html and then once logged in, it will change the state to home.html. I could really use some help doing this. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
The ion-content creates its own child scope. Try declaring a main scope object in your controller: .controller('LoginCtrl', function($scope, $rootScope, $http, $state) { $scope.data = {} In your template: In your login submit: var username = $scope.data.fName + " " + $scope.data.lName;

Related questions

0 votes
    can anyone help me.. [NSString stringWithFormat:@"document.getElementsByTagName('body')[0].style.textAlign = ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    How can we take input text from user in HTML page? (a) input tag (b) inoutBufferedReader tag (c) meta ... & Servlet of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
0 votes
    I have an HTML page that contains some filenames that i want to download from a webserver. I need ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 13, 2022 in Education by JackTerrance
0 votes
    How can we take input text from user in HTML page? (a) input tag (b) inoutBufferedReader tag (c) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    I have one weird requirement that in my existing app I have Text2Speech and for that, I have used ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I'm trying to change the color of text lines containing "Accepted" to green and all others to red ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    Why text inside / list is not affected (color of "item1", "item2" is not changed) by CSS applied ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    Why text inside / list is not affected (color of "item1", "item2" is not changed) by CSS applied ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 29, 2022 in Education by JackTerrance
0 votes
    Why text inside / list is not affected (color of "item1", "item2" is not changed) by CSS applied ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    It took me forever to reduce the problem to this. I cannot express the amount of frustration I'm ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    How can I replace a specific text with HTML objects? example: var text = "some text to replace ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    How can I replace a specific text with HTML objects? example: var text = "some text to replace ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Write html code to set the BGCOLOR as NAVY, header 1 text Text Example with size, colour and font face'' as ... font face ARIAL . Select the correct answer from above options...
asked Dec 29, 2021 in Education by JackTerrance
0 votes
    which section is used for text and tags that are shown directly on your web page? A head B body. c title. d HTML Select the correct answer from above options...
asked Dec 27, 2021 in Education by JackTerrance
0 votes
    which section is used for text and tags that are shown directly on your web page? A head B body. c title. d HTML Select the correct answer from above options...
asked Dec 26, 2021 in Education by JackTerrance
...