Mpondomise Mpondomise - 1 month ago 7
AngularJS Question

angularjs ng-hide element based on firebase mode

Refering to this documentation here, I am trying to hide my element if the

mode
in the controller function is
verifyEmail
.
No success.
Could somebody help to see why it doesn't work?

my html is like:



<div class="box-forgot" ng-controller="ResetPass">
<form class="form-forgot" name="resetpassword" ng-hide="mode == 'verifyEmail'">
<fieldset>
<legend>
Reset Password:
</legend>

<div class="form-group">
<span class="input-icon">
<input type="password" class="form-control" id="password" ng-model="user.password" name="password" placeholder="Password" required="">
<i class="fa fa-lock"></i> </span>

</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary pull-right" ng-click="resetMe()">
Reset
</button>
</div>
</fieldset>
</form>
</div>


and the corresponding controller is:



app.controller("ResetPass", ["$scope","firebase", "$location",
function ($scope,firebase, $location) {

$scope.resetMe = function () {
var newPassword = $scope.user.password;
var actionCode = $location.search().oobCode;
var mode = $location.search().mode;
firebase.auth().confirmPasswordReset(actionCode, newPassword)
.then(function (resp) {
console.log("reset pass, done");
$location.path('/login.signin');
}).catch(function (error) {
$scope.errMsg = true;
$scope.errorMessage = error.message;
});
}
}]);

Answer

Try to bind mode with $scope object instead of var

Instead of

    var mode = $location.search().mode;

Do this

    $scope.mode = $location.search().mode;