dev:browser_staff:examples
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| dev:browser_staff:examples [2018/12/14 11:20] – adding angular section sandbergja | dev:browser_staff:examples [2023/06/01 13:20] (current) – [Edit the tt2 template] master to main dyrcona | ||
|---|---|---|---|
| Line 15: | Line 15: | ||
| @Component({ | @Component({ | ||
| - | selector: ' | ||
| template: '< | template: '< | ||
| }) | }) | ||
| Line 27: | Line 26: | ||
| < | < | ||
| - | import {EgMathComponent} from ' | + | import {EgMathComponent} from ' |
| import {RouterModule, | import {RouterModule, | ||
| Line 55: | Line 54: | ||
| Re-compile, the client, and you should see your brand new screen at https:// | Re-compile, the client, and you should see your brand new screen at https:// | ||
| + | === Add another component with an OpenSRF call === | ||
| + | |||
| + | Create a new .ts file in Open-ILS/ | ||
| + | |||
| + | < | ||
| + | import {Component, OnInit} from ' | ||
| + | import {NetService} from ' | ||
| + | |||
| + | @Component({ | ||
| + | selector: ' | ||
| + | templateUrl: | ||
| + | }) | ||
| + | export class AdderComponent implements OnInit { | ||
| + | sum: number = 0; | ||
| + | addTwoNumbers: | ||
| + | |||
| + | constructor( | ||
| + | private net: NetService | ||
| + | ){} | ||
| + | |||
| + | ngOnInit() { | ||
| + | this.addTwoNumbers = (first: number = 0, second: number = 0) => { | ||
| + | this.net.request( | ||
| + | ' | ||
| + | ' | ||
| + | first, second) | ||
| + | .subscribe(response => this.sum = response); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | This has some differences from our first one. First of all, it has a selector, which means that we can include it in other components by saying < | ||
| + | |||
| + | < | ||
| + | <label i18n> | ||
| + | <label i18n> | ||
| + | <button (click)=" | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | Let's update our module to let it know about the new component: | ||
| + | |||
| + | < | ||
| + | import {EgMathComponent} from ' | ||
| + | import {AdderComponent} from ' | ||
| + | import {RouterModule, | ||
| + | |||
| + | |||
| + | const routes: Routes = [{ | ||
| + | path: ' | ||
| + | component: EgMathComponent | ||
| + | }]; | ||
| + | |||
| + | |||
| + | @NgModule({ | ||
| + | imports: [RouterModule.forChild(routes)], | ||
| + | exports: [RouterModule], | ||
| + | declarations: | ||
| + | }) | ||
| + | export class MathModule { }</ | ||
| + | |||
| + | Finally, let's update our first component' | ||
| ===== AngularJs ===== | ===== AngularJs ===== | ||
| Line 156: | Line 218: | ||
| </ | </ | ||
| - | Note: Evergreen has several other built-in types of modals, such as egConfirmDialog, | + | Note: Evergreen has several other built-in types of modals, such as egConfirmDialog, |
| ====Add an egGrid to your screen==== | ====Add an egGrid to your screen==== | ||
dev/browser_staff/examples.1544804432.txt.gz · Last modified: 2022/02/10 13:34 (external edit)