javascript - using ng-hide to display/hide buttons based on a condition -


i have 3 buttons in mark-up 2 of being hidden. this:

<button ng-click="validate()">submit</button><br /> <button id="retryquiz" ng-hide="true" onclick="location.reload(true);">retry</button> <button id="getcertificate" ng-hide="true" onclick="printdoc()">print doc</button> 

now need ng-hide somehow evaluate value coming validate() function , based on "if" statement show 1 or other again. instance, if result validate more 50% show print doc, , if less 50% show button retry.

just how attach html portion of .js file?

it's best have function on scope return boolean according condition, when conditions more complicated. can have condition on controller or use parameters:

<button id="retryquiz" ng-hide="hideretry()" onclick="location.reload(true);">retry</button> 

and in controller:

$scope.hideretry = function () {     return $scope.validate() >= 50; } 

this way, "retry" button hide if result $scope.validate() higher 50%.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -