---
# System prepended metadata

title: TB widget develop
tags: [' ThingsBoard', Ongoing]

---

---
title: TB widget develop
tags: Ongoing, ThingsBoard
---


## Custom Service Injection ( rebuild needed )

1. Create service.ts
	* `ng g s /path/to/customService`
2. Add custom Service into servicesMap
	* path - `src/app/modules/home/models/services.map.ts`
	```
	export const ServicesMap = new Map<string, Type<any>>(
	  [
	+  ['customService', CustomService],
	   ['broadcastService', BroadcastService],
	   ['deviceService', DeviceService],
	   ['alarmService', AlarmService],
	   ...
	```
3. Get service
	```
	let customService = self.ctx.$scope.$injector.get(self.ctx.servicesMap.get('customService'));
	```
	
## Custom Action

* Default tag
	1. `<link-act name="actionName">link</link-act>`
	2. `<button-act name="actionName">button</button-act>`

* Custom tag
	* add `class="tb-custom-action"` & `data-action-name="actionName"` to binding custom action
	* example: 	
	`<button class="tb-custom-action" data-action-name="actionName"></button>`
