# Service Development

A Servoy service is a plain Angular service with the [@Injectable()](https://angular.dev/tutorials/learn-angular/19-creating-an-injectable-service) annotation

It should just be correctly configured in the [manifest](/reference/extension-dev/component_services/manifest.md) and also in the [specfile](/reference/extension-dev/component_services/spec-file.md).

The spec file should container stuff like:

```json
"ng2Config": { 
       "packageName": "@servoy/webnotifications",
       "serviceName": "WebNotificationsService",
       "moduleName": "WebNotificationsModule",
       "entryPoint": "dist/servoy/webnotifications"
    },
```

the packageName should be the same as in the manifest:

```
NPM-PackageName: @servoy/webnotifications
```

and the serviceName should be the same as the name of the class:

```typescript
@Injectable()
export class WebNotificationsService {
}
```

also the module name is needed so that your service can include everything it needs in its module:

```typescript
@NgModule({
    declarations: [],
    providers: [WindowRefService, WebNotificationsService, ServoyToastrService, ToastrService],
    imports: [
        CommonModule,
        ServoyPublicModule,
        ToastrModule.forRoot()
    ],
    exports: []
})
export class WebNotificationsModule {}
```

The entry point is just for servoy to know where the distribution (build output of the angular compiler) is in the package.

After that the model properties are just public fiels of the service and api are just public functions.

If it is needed that you want todo something when a property is changed you can just get/set in typescript:

```typescript
get onIdle(): CallableFunction {
  return this._onIdle;
}

set onIdle(callback: CallableFunction) {
  this._onIdle = callback;
  this.restoreOnIdleState();
}
```

this sample does call restoreOnIdleState() when the onIdle model property is set.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/reference/extension-dev/component_services/servoyservice.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
