I have developed a cross-platform application using AngularJS, Monaca, and OnsenUI.
In my login view, I check if the user has previously logged in by querying a SQLite database. Depending on whether there is data in the database, I either display a welcome message to the user or show the login text field.
I have successfully implemented a method to query the SQLite database. When a record is found in the database, I set a boolean value to show the welcome message; otherwise, it displays the login text field.
Within my view, I include the following code;
<!-- User not in DB -->
<div ng-if="showLoginUI">
<div class="input">
<input type="password" placeholder="User ID" ng-model="userID"/>
</div>
</div>
I monitor changes in the text field to capture user input, but no actions are recorded as shown above. This is the approach I use to track user interactions with the text field.
$scope.$watch("userID", function (newVal, oldVal)
{
if (newVal !== oldVal) {
$scope.newUserID = newVal; // Not getting here
}
});
However, when I remove the ng-if statement from the example above, the user events are captured. How can I retain the ng-if while still tracking events on the text field?
I attempted to incorporate a $timeout in my $watch function, but this did not resolve the issue.