angular ui bootstrap - how to close modal after submit in angularjs -
i know have many result in question no 1 give work answer me.
html 1:
<button class="basebtn logbtn" ng-click="openlog()">login</button> <button class="basebtn regbtn" ng-click="openreg()">sign up</button>
html 2:
<div ng-controller="main"> <center><img class="img-login" ng-src="../images/form-logo.png"/></center> <form class="login" name="log" ng-submit="login()" novalidate> <div class="form-group login-form" ng-class="{'has-error' : isinvalid(log.email) ,'has-success' : isvalid(log.email)}"> <input type="email" class="form-control" name="email" ng-model="user.email" required placeholder="email"> <div class="alert alert-danger" role="alert" ng-show="isinvalid(log.email)">enter valid email</div> </div> <div class="form-group login-form" ng-class="{'has-error' : isinvalid(log.password) ,'has-success' : isvalid(log.password)}"> <input type="password" class="form-control" name="password" ng-model="user.password" required placeholder="password"> <div class="alert alert-danger" role="alert" ng-show="isinvalid(log.password)">this feild required</div> </div> <div class="form-group" style="text-align:center;"> <input type="submit" class="logbnt" value="login" ng-disabled="! log.$valid" data-dismiss='modal'/> </div> </form>
angular :
$scope.login = function(){ $http.post("www.example.com/login",$scope.user).then(function(res){ localstorage.setitem("token",res.data.token); //how close modal ??? }); } //here create modal $scope.openlog = function () { $scope.$modalinstance = $uibmodal.open({ templateurl:"login.html", }); }
that code , how close in $http result modal ?
you can this,
$scope.login = function(){ $http.post("www.example.com/login",$scope.user).then(function(res){ localstorage.setitem("token",res.data.token); $modalinstance.dismiss('cancel'); }); };
Comments
Post a Comment