settings-unit-test v0.0.0-watch
Settings
This library was generated with Angular CLI version 12.2.0.
Code scaffolding
Run ng generate component component-name --project settings
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module --project settings
.
Note: Don't forget to add
--project settings
or else it will be added to the default project in yourangular.json
file.
Build
Run ng build settings
to build the project. The build artifacts will be stored in the dist/
directory.
Publishing
After building your library with ng build settings
, go to the dist folder cd dist/settings
and run npm publish
.
Running unit tests
Run ng test settings
to execute the unit tests via Karma.
Further help
To get more help on the Angular CLI use ng help
or go check out the Angular CLI Overview and Command Reference page.
Implementation example
<ion-button expand="full" (click)="openSettings()">Settings</ion-button>
import { SettingsService } from '@emp/settings';
export interface Option {
id: string,
name: string,
checked: boolean
}
options: Option[] = [
{
id: "push_notifications",
name: "Push notifications",
checked: false
},
{
id: "quick_access",
name: "Quick access",
checked: false
}
]
// In the constructor, subscribe the options observer
constructor(private router: Router, private settings: SettingsService) {
this.settings.optionsSubjectObs.subscribe(
option=>
console.log(option.id, option.checked)
)
}
Properties
Property | Description | Type | Default |
---|---|---|---|
id | ID to get the item from toggleCheckChanged. | string | empty |
name | Settings option name. | string | Default Label |
checked | Boolean to indicate the toggle status. | boolean | false |
Events
Event | Description | Type |
---|---|---|
toggleCheckChanged | Method to grab the toggle event | CustomEvent<{ id: string, checked: boolean }> |
2 years ago