javascript - ng-hide ng-show clarification needed -
i have 2 forms in 1 page client side web app in angular js/javascript
i got 2 forms
<form class="simple-form" ng-submit="createuser()"> log in as: <input type="text" ng-model="name.username"> <input type="submit"/> </form>
the createuser() method pushing object array of objects.
$scope.createuser = function createuser() { var safer = angular.copy($scope.name); $scope.users.push(safer);}; $scope.users = [ {'username': 'john'}, {'username': 'dan'}, {'username': 'judy'}, {'username': 'michael'}, {'username': 'rebecca'}, {'username': 'macy'}, {'username': 'ross'} ];
i have form message container, want submit message show when new user got created
<div class="message_container"> <p ng-repeat="message in messages"> {{message.post}} </p> <form class="post-form" ng-submit="postmessage()" ng-show="createuser()"> <input type="text" ng-model="message.post"> <input type="submit"/> </form> </div>
i trying use ng-hide , ng-show this. thinking form should show when ng-submit="createuser()" createuser() ended creating users blank ones because method , looking expression. should using ng-show , ng-hide, maybe should use else instead.
ng-show
, ng-hide
need expression determine status. set flag true
when create new user:
$scope.createuser = function createuser() { var safer = angular.copy($scope.name); $scope.users.push(safer); $scope.isnewuser = true; } <form class="post-form" ng-submit="postmessage()" ng-show="isnewuser">
Comments
Post a Comment