Skip to content

Commit 0826dbe

Browse files
authored
update angular version and add standalone components (#55)
1 parent 3ac7fc6 commit 0826dbe

34 files changed

+8945
-6988
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [1.6.0] - 2025-05-08
5+
### Change
6+
- Update to Angular 14
7+
- Introduce standole component
8+
49
## [1.5.3] - 2024-07-20
510
### Added
611
- Add `textAlign` input property ([#53](https://github.com/vicmans/ng-toggle-button/issues/53))

README.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This is a toggle switch button component, you can see the demo [here][demo-url]
1414

1515
| Angular | ng-toggle-button|
1616
| -------- |:------:|
17+
| >=16.0.0 | v1.6.x |
1718
| >=15.0.0 | v1.5.x |
1819
| >=14.0.0 | v1.4.x |
1920
| >=13.0.0 | v1.3.x |
@@ -37,15 +38,30 @@ yarn add ng-toggle-button
3738

3839
## Usage
3940

40-
Import the module
41+
### Standalone: Import the component.
42+
43+
```typescript
44+
import { NgToggleComponent } from 'ng-toggle-button';
45+
@Component({
46+
selector: 'your-component',
47+
standalone: true,
48+
imports: [
49+
...,
50+
NgToggleComponent,
51+
],
52+
...
53+
})
54+
```
55+
56+
### NgModule: Import the module
4157

4258
```typescript
4359
import { NgToggleModule } from 'ng-toggle-button';
4460
@NgModule({
4561
...
4662
imports: [
4763
...,
48-
NgToggleModule.forRoot() //or NgToggleModule
64+
NgToggleModule
4965
],
5066
})
5167
```
@@ -63,9 +79,19 @@ import { NgToggleModule } from 'ng-toggle-button';
6379
})
6480
```
6581

66-
The `config` object is described in the table bellow
82+
You can edit the configuration globally by injecting `NgToggleConfig` service usually in the root component.
6783

68-
Use
84+
```ts
85+
constructor(private config: NgToggleConfig) {
86+
this.config.labels: {
87+
unchecked: 'off',
88+
checked: 'on',
89+
};
90+
this.config.color = 'crimson';
91+
}
92+
```
93+
94+
Usage in template
6995

7096
```html
7197
<ng-toggle
@@ -77,6 +103,8 @@ Use
77103
></ng-toggle>
78104
```
79105

106+
The `config` object is described in the table bellow
107+
80108
### Properties
81109

82110
| Name | Type | Default | Description |

angular.json

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
"test": {
2020
"builder": "@angular-devkit/build-angular:karma",
2121
"options": {
22-
"main": "projects/ng-toggle/src/test.ts",
2322
"tsConfig": "projects/ng-toggle/tsconfig.spec.json",
24-
"karmaConfig": "projects/ng-toggle/karma.conf.js"
23+
"polyfills": [
24+
"zone.js",
25+
"zone.js/testing"
26+
]
2527
}
2628
}
2729
}
@@ -39,7 +41,9 @@
3941
"outputPath": "dist/demo",
4042
"index": "projects/demo/src/index.html",
4143
"main": "projects/demo/src/main.ts",
42-
"polyfills": "projects/demo/src/polyfills.ts",
44+
"polyfills": [
45+
"zone.js"
46+
],
4347
"tsConfig": "projects/demo/tsconfig.app.json",
4448
"aot": false,
4549
"assets": [
@@ -105,9 +109,11 @@
105109
"builder": "@angular-devkit/build-angular:karma",
106110
"options": {
107111
"main": "projects/demo/src/test.ts",
108-
"polyfills": "projects/demo/src/polyfills.ts",
112+
"polyfills": [
113+
"zone.js",
114+
"zone.js/testing"
115+
],
109116
"tsConfig": "projects/demo/tsconfig.spec.json",
110-
"karmaConfig": "projects/demo/karma.conf.js",
111117
"assets": [
112118
"projects/demo/src/favicon.ico",
113119
"projects/demo/src/assets"
@@ -117,18 +123,6 @@
117123
],
118124
"scripts": []
119125
}
120-
},
121-
"e2e": {
122-
"builder": "@angular-devkit/build-angular:protractor",
123-
"options": {
124-
"protractorConfig": "projects/demo/e2e/protractor.conf.js",
125-
"devServerTarget": "demo:serve"
126-
},
127-
"configurations": {
128-
"production": {
129-
"devServerTarget": "demo:serve:production"
130-
}
131-
}
132126
}
133127
}
134128
}

0 commit comments

Comments
 (0)