forked from simpleangularcontrols/simpleangularcontrols
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Access to NgForm with sacInheritForm directive (simpleangul…
- Loading branch information
1 parent
6b41c5e
commit fb22ba4
Showing
14 changed files
with
306 additions
and
162 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
ch.jnetwork.sac-controls/projects/demo-bootstrap3/src/app/form/subform.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 29 additions & 14 deletions
43
ch.jnetwork.sac-controls/projects/demo-bootstrap3/src/app/form/subform.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,40 @@ | ||
import { Component } from '@angular/core'; | ||
import { Input } from '@angular/core'; | ||
import { EventEmitter } from '@angular/core'; | ||
import { Output } from '@angular/core'; | ||
import { DoCheck } from '@angular/core'; | ||
import { | ||
Component, | ||
DoCheck, | ||
EventEmitter, | ||
Input, | ||
Output, | ||
ViewChild, | ||
} from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { SACBootstrap3FormModule, SACBootstrap3InputModule } from '@simpleangularcontrols/sac-bootstrap3'; | ||
|
||
import { | ||
SACBootstrap3FormModule, | ||
SACBootstrap3InputModule, | ||
} from '@simpleangularcontrols/sac-bootstrap3'; | ||
|
||
@Component({ | ||
selector: 'app-subform', | ||
templateUrl: './subform.component.html', | ||
standalone: true, | ||
imports: [SACBootstrap3FormModule, SACBootstrap3InputModule, FormsModule] | ||
selector: 'app-subform', | ||
templateUrl: './subform.component.html', | ||
standalone: true, | ||
imports: [SACBootstrap3FormModule, SACBootstrap3InputModule, FormsModule], | ||
}) | ||
export class DemoSubFormComponent implements DoCheck { | ||
// #region Properties | ||
|
||
@Input() public mymodel; | ||
@Output() public mymodelChange = new EventEmitter(); | ||
@ViewChild('formaccess') public form: SacInheritFormDirective; | ||
|
||
// #endregion Properties | ||
|
||
@Input() mymodel; | ||
@Output() mymodelChange = new EventEmitter(); | ||
// #region Public Methods | ||
|
||
ngDoCheck() { | ||
public ngDoCheck() { | ||
if (this.form) { | ||
console.log(this.form.getForm().dirty); | ||
} | ||
this.mymodelChange.next(this.mymodel); | ||
} | ||
|
||
// #endregion Public Methods | ||
} |
2 changes: 1 addition & 1 deletion
2
ch.jnetwork.sac-controls/projects/demo-bootstrap4/src/app/form/subform.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 29 additions & 14 deletions
43
ch.jnetwork.sac-controls/projects/demo-bootstrap4/src/app/form/subform.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,40 @@ | ||
import { Component } from '@angular/core'; | ||
import { Input } from '@angular/core'; | ||
import { EventEmitter } from '@angular/core'; | ||
import { Output } from '@angular/core'; | ||
import { DoCheck } from '@angular/core'; | ||
import { | ||
Component, | ||
DoCheck, | ||
EventEmitter, | ||
Input, | ||
Output, | ||
ViewChild, | ||
} from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { SACBootstrap4FormModule, SACBootstrap4InputModule } from '@simpleangularcontrols/sac-bootstrap4'; | ||
|
||
import { | ||
SACBootstrap4FormModule, | ||
SACBootstrap4InputModule, | ||
} from '@simpleangularcontrols/sac-bootstrap4'; | ||
|
||
@Component({ | ||
selector: 'app-subform', | ||
templateUrl: './subform.component.html', | ||
standalone: true, | ||
imports: [SACBootstrap4FormModule, SACBootstrap4InputModule, FormsModule] | ||
selector: 'app-subform', | ||
templateUrl: './subform.component.html', | ||
standalone: true, | ||
imports: [SACBootstrap4FormModule, SACBootstrap4InputModule, FormsModule], | ||
}) | ||
export class DemoSubFormComponent implements DoCheck { | ||
// #region Properties | ||
|
||
@Input() public mymodel; | ||
@Output() public mymodelChange = new EventEmitter(); | ||
@ViewChild('formaccess') public form: SacInheritFormDirective; | ||
|
||
// #endregion Properties | ||
|
||
@Input() mymodel; | ||
@Output() mymodelChange = new EventEmitter(); | ||
// #region Public Methods | ||
|
||
ngDoCheck() { | ||
public ngDoCheck() { | ||
if (this.form) { | ||
console.log(this.form.getForm().dirty); | ||
} | ||
this.mymodelChange.next(this.mymodel); | ||
} | ||
|
||
// #endregion Public Methods | ||
} |
2 changes: 1 addition & 1 deletion
2
ch.jnetwork.sac-controls/projects/demo-bootstrap5/src/app/form/subform.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...sac-controls/projects/sac-bootstrap3/src/controls/form/inheritform.directive.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Examples | ||
|
||
## Inherit Form | ||
|
||
```html | ||
<div sacInheritForm> | ||
<div>SubForm</div> | ||
<div> | ||
<ngInput [(ngModel)]="mymodel.fieldarea2" name="subformField3" label="field 3" [isrequired]="true"></ngInput> | ||
</div> | ||
</div> | ||
``` | ||
|
||
## Inherit Form with access to Form | ||
|
||
HTML Template with access to form. | ||
|
||
```html | ||
<div sacInheritForm #formaccess="sacinheritform"> | ||
<div>SubForm</div> | ||
<div> | ||
<ngInput [(ngModel)]="mymodel.fieldarea2" name="subformField3" label="field 3" [isrequired]="true"></ngInput> | ||
</div> | ||
</div> | ||
``` | ||
|
||
Code behind file with access to form. | ||
|
||
```ts | ||
import { Component, Input, Output, ViewChild } from '@angular/core'; | ||
import { SacInheritFormDirective } from '@simpleangularcontrols/sac-bootstrap3'; | ||
|
||
@Component({ | ||
selector: 'app-subform', | ||
templateUrl: './subform.component.html', | ||
}) | ||
export class DemoSubFormComponent { | ||
@Input() mymodel; | ||
@Output() mymodelChange = new EventEmitter(); | ||
@ViewChild('formaccess') public form: SacInheritFormDirective; | ||
|
||
public accessToForm() { | ||
console.log(this.form.getForm().dirty); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...sac-controls/projects/sac-bootstrap4/src/controls/form/inheritform.directive.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Examples | ||
|
||
## Inherit Form | ||
|
||
```html | ||
<div sacInheritForm> | ||
<div>SubForm</div> | ||
<div> | ||
<ngInput [(ngModel)]="mymodel.fieldarea2" name="subformField3" label="field 3" [isrequired]="true"></ngInput> | ||
</div> | ||
</div> | ||
``` | ||
|
||
## Inherit Form with access to Form | ||
|
||
HTML Template with access to form. | ||
|
||
```html | ||
<div sacInheritForm #formaccess="sacinheritform"> | ||
<div>SubForm</div> | ||
<div> | ||
<ngInput [(ngModel)]="mymodel.fieldarea2" name="subformField3" label="field 3" [isrequired]="true"></ngInput> | ||
</div> | ||
</div> | ||
``` | ||
|
||
Code behind file with access to form. | ||
|
||
```ts | ||
import { Component, Input, Output, ViewChild } from '@angular/core'; | ||
import { SacInheritFormDirective } from '@simpleangularcontrols/sac-bootstrap4'; | ||
|
||
@Component({ | ||
selector: 'app-subform', | ||
templateUrl: './subform.component.html', | ||
}) | ||
export class DemoSubFormComponent { | ||
@Input() mymodel; | ||
@Output() mymodelChange = new EventEmitter(); | ||
@ViewChild('formaccess') public form: SacInheritFormDirective; | ||
|
||
public accessToForm() { | ||
console.log(this.form.getForm().dirty); | ||
} | ||
} | ||
``` |
Oops, something went wrong.