I have been able to create a function to successfully toggle the rows in my ng-table to expand on click, however, when clicking them again they will not hide. The function in the javascript is:
$scope.toggle = function() {
return !this.booleanVal;
};
The booleanVal
is being a value from the json
file (each row with its own value). Then in the HTML.
<p class="row_description more" ng-click="row.booleanVal = toggle()">{{row.description}</p>
<div class="check-element animate-show" ng-show="row.booleanVal">
It works for the first click, turning the previously false booleanVal
to true
, however, it doesn't toggle
back to false
. Any idea what's going wrong?
For a single btn, it's ok to use ng-click or onclick in the ng-app . There is no difference between the two functions. For effective team work, you,d better to have an account with each other. In Angular apps, ng-click is recommended.
Another significant difference between ng-click and onclick is the execution context. Code inside an onclick attribute executes against the global window object, while an expression inside of ng-click executes against a specific scope object, typically the scope object representing the model for the current controller.
In this article, we will learn how to get many/multiple functions to the ng-click directive passed, in just one click. The key is to add a semi-colon (;) or a comma (,). All the functions must be separated by a (;) or a (, ). This syntax is supported by all the elements in the HTML.
Try this:
<p class="row_description more" ng-click="row.booleanVal = !row.booleanVal">
{{row.description}
</p>
<div class="check-element animate-show" ng-show="row.booleanVal"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With