Guest User

Untitled

a guest
Dec 11th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. export class Form {
  2. constructor(){
  3. var today = new Date(),
  4. dd = today.getDate(),
  5. mm = today.getMonth() + 1,
  6. yyyy = today.getFullYear();
  7.  
  8. if(dd < 10) dd = `0${dd}`;
  9. if(mm < 10) mm = `0${mm}`;
  10.  
  11. today = `${yyyy}-${mm}-${dd}`;
  12.  
  13. this.balance.dateTo = today;
  14. }
  15.  
  16. public balance = {
  17. viewBy: 'Ad1',
  18. companyUnit: 'DEPED',
  19. financialYear: '2016',
  20. clients: 'Dummy Text 1'
  21. };
  22. }
  23.  
  24. import { Form } from '../form'; // path is correct
  25.  
  26. export class BalanceComponent {
  27. form: Form; // I am not sure of it
  28. // this is the place I want to import repeated class
  29. search_data(balance){
  30. console.log(balance);
  31. }
  32. }
  33.  
  34. (function (global) {
  35. System.config({
  36. paths: {
  37. // paths serve as alias
  38. 'npm:': 'node_modules/'
  39. },
  40. // map tells the System loader where to look for things
  41. map: {
  42. // our app is within the app folder
  43. app: 'app',
  44. // angular bundles
  45. '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
  46. '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
  47. '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
  48. '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
  49. '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
  50. '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
  51. '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
  52. '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
  53. 'ng2-pagination': 'npm:/ng2-pagination',
  54. // other libraries
  55. 'rxjs': 'npm:rxjs',
  56. 'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',
  57. },
  58.  
  59. // packages tells the System loader how to load when no filename and/or no extension
  60. packages: {
  61. app: {
  62. main: './main.js',
  63. defaultExtension: 'js'
  64. },
  65. rxjs: {
  66. defaultExtension: 'js'
  67. },
  68. 'angular-in-memory-web-api': {
  69. main: './index.js',
  70. defaultExtension: 'js'
  71. },
  72. 'ng2-pagination': {
  73. main: 'index.js', defaultExtension: 'js'
  74. }
  75. }
  76. });
  77. })(this);
  78.  
  79. export class BalanceComponent {
  80. form: Form;
  81.  
  82. constructor() {
  83. this.form = new Form();
  84. }
  85. }
  86.  
  87. export class BalanceComponent {
  88. constructor(private formService:FormService) {}
  89. }
  90.  
  91. @Injectable()
  92. export class FormService {
  93. constructor(){
  94. var today = new Date(),
  95. dd = today.getDate(),
  96. mm = today.getMonth() + 1,
  97. yyyy = today.getFullYear();
  98.  
  99. if(dd < 10) dd = `0${dd}`;
  100. if(mm < 10) mm = `0${mm}`;
  101.  
  102. today = `${yyyy}-${mm}-${dd}`;
  103.  
  104. this.balance.dateTo = today;
  105. }
  106.  
  107. public balance = {
  108. viewBy: 'Ad1',
  109. companyUnit: 'DEPED',
  110. financialYear: '2016',
  111. clients: 'Dummy Text 1'
  112. };
  113. }
  114.  
  115. @NgModule({
  116. imports: [CommonModule],
  117. declarations: [BalanceComponent],
  118. exports: [BalanceComponent]
  119. })
  120. export class SharedModule {
  121. static forRoot(): ModuleWithProviders {
  122. return {
  123. ngModule: SharedModule,
  124. providers: [FormService]
  125. };
  126. }
  127. }
  128.  
  129. @NgModule({
  130. imports: [
  131. /** other modules import **/
  132. SharedModule.forRoot(), // you can also pass some config here if needed
  133. routing
  134. ],
  135. declarations: [ AppComponent ],
  136. bootstrap: [ AppComponent ]
  137. })
  138. export class AppModule { }
Add Comment
Please, Sign In to add comment