- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2023 04:28 PM
Hi everyone! How are you?!
There is a select options element in the data-table, but "angle-down" does not rotate 180 degrees when clicked, so I am checking the possibility of using DOM manipulation, like this:
HTML:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2023 04:56 PM
I would use AngularJS as much as possible and employ conditional style; something along the lines of:
Body HTML template:
<div>
<input ng-model="rotate" type="checkbox" />
<div>{{rotate}}</div>
<div class="container-icon" ng-click="rotate = !rotate">
<i class="fa fa-angle-down" ng-class="{ 'faceUp': !rotate, 'faceDown': rotate }"></i>
</div>
</div>
CSS:
.faceUp {
color: red;
transform: rotate(0deg);
}
.faceDown {
color: blue;
transform: rotate(180deg);
}
Client controller:
api.controller = function ($scope) {
var c = this;
$scope.rotate = false;
};
There is a lot of extra stuff in the example, but it will make testing easier.
The idea is that you define a scope property and "link" the style of the element to that property. Then all you have to do is to update that scope property as needed. In this example the scope properties value is tied to clicking the chevron and to marking the check box. One could also define a function on the scope that would do the same:
The modified portion of the Body HTML template:
...
<div class="container-icon" ng-click="flipRotate()">
...
The new Client controller:
api.controller = function ($scope) {
var c = this;
$scope.flipRotate = flipRotate;
$scope.rotate = false;
function flipRotate () {
$scope.rotate = !$scope.rotate;
}
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2023 04:56 PM
I would use AngularJS as much as possible and employ conditional style; something along the lines of:
Body HTML template:
<div>
<input ng-model="rotate" type="checkbox" />
<div>{{rotate}}</div>
<div class="container-icon" ng-click="rotate = !rotate">
<i class="fa fa-angle-down" ng-class="{ 'faceUp': !rotate, 'faceDown': rotate }"></i>
</div>
</div>
CSS:
.faceUp {
color: red;
transform: rotate(0deg);
}
.faceDown {
color: blue;
transform: rotate(180deg);
}
Client controller:
api.controller = function ($scope) {
var c = this;
$scope.rotate = false;
};
There is a lot of extra stuff in the example, but it will make testing easier.
The idea is that you define a scope property and "link" the style of the element to that property. Then all you have to do is to update that scope property as needed. In this example the scope properties value is tied to clicking the chevron and to marking the check box. One could also define a function on the scope that would do the same:
The modified portion of the Body HTML template:
...
<div class="container-icon" ng-click="flipRotate()">
...
The new Client controller:
api.controller = function ($scope) {
var c = this;
$scope.flipRotate = flipRotate;
$scope.rotate = false;
function flipRotate () {
$scope.rotate = !$scope.rotate;
}
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2023 10:54 AM
Hello @-O- ! How are you?!
I was studying a much more complex way to include DOM in the Link part of the Widget and it certainly could not work, but your suggestions will be very useful, with the use of Angular (ng-click and ng-class).
This condition with booleans also made me understand everything more clearly.
Thank you very much for your attention, support and for sharing your extensive knowledge with us in the community!
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2023 10:56 AM
Hello, I'm fine, thanks!
Hope you are too and you're most welcome 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2023 05:00 PM
Also, when dealing with AngularJS one should not access the DOM. You can never know when it works as AngularJS can remove/destroy any time any node you may rely and and replace those with other nodes which will no longer react to or emit events as the ones you originally wired up.