问题
This issue is very similar to Thingsboard Dashboard Custom Action NullInjectorError
I setup Entities table widget with Datasources from Entity alias like "Entity Views of type 'power_sensor'".
The idea is simple:
- if Entity View's name is "Powermeter1" - then goto Dashboard state 1
- else if it is called "Powermeter2" - goto Dashboard state 2
Now I'm going to create Custom action for “On row click ” but fail. I rty to modify @lee-sangjun's code according to entity.service API like this:
var $injector = widgetContext.$scope.$injector;
$injector.get(widgetContext.entityService.get('entityViewService')).getEntity(entityId.id).subscribe(function(entity) {
if (entity.name == 'Powermeter1') {
openDashboardState('energy_state_1')
}
else if(entity.name == 'Powermeter2') {
openDashboardState('water_state_2')
}
});
function openDashboardState(stateId) {
var params = {
entityId: entityId,
entityName: entityName
}
widgetContext.stateController.openState(stateId, params,
false);
}
But nothing happens. What I have to do to make it work?
来源:https://stackoverflow.com/questions/62718109/thingsboard-dashboard-entities-table-with-entity-views