I'm trying to make a custom widget on Thingsboard that would change the text when it's pressed. Like this: Custom Widget creation
But it's not working at all. What am I doing wrong?
I'm trying to make a custom widget on Thingsboard that would change the text when it's pressed. Like this: Custom Widget creation
But it's not working at all. What am I doing wrong?
Did you read the official widgets development guide?
There are some examples that use click-events
https://thingsboard.io/docs/user-guide/contribution/widgets-development/#static-widget
Thingsboard uses AngularJS, so you can bind click-handlers to elements with the ng-click
attribute like this:
<p id="text" ng-click="changeText()">Text</p>
To make this work you will need to create that click-handler in the widget's scope. The perfect place to do this is the onInit()
method of the widget.
self.onInit = function() {
self.ctx.$scope.changeText = function() {
// change your text here
};
};