Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 KB | None | 0 0
  1. module Application.Controller {
  2.     import Services = Application.Services;
  3.     var controllersModule = angular.module('controllers', []);
  4.  
  5.     export interface CompanyScope extends ng.IScope {
  6.         name: string;
  7.     }
  8.  
  9.     export interface PersonScope extends ng.IScope {
  10.         name: string;
  11.         person: Person;
  12.     }
  13.  
  14.     type Person = {
  15.         dob: string;
  16.         name: string;
  17.         age?: number;
  18.     }
  19.  
  20.  
  21.     class CompanyController {
  22.  
  23.         static AngularDependency = ['$scope'];
  24.         constructor(private $scope: CompanyScope) {
  25.             this.companyName();
  26.         }
  27.  
  28.         private companyName() {
  29.             this.$scope.name = "Veripark";          
  30.         }
  31.     }
  32.  
  33.     class PersonController {
  34.         static AngularDependency = ['$scope', 'ageService'];
  35.         ageService: Application.Services.AgeService;
  36.         constructor(private $scope: PersonScope, ageService: Application.Services.AgeService) {          
  37.             this.ageService = ageService;
  38.             this.initController();
  39.         }
  40.  
  41.         private initController() {
  42.             this.$scope.name = 'Berkin';
  43.             this.$scope.person = { name: 'Berkin', dob: '01-01-1995' };
  44.             this.$scope.person.age = this.ageService.calculateAge(this.$scope.person.dob);
  45.         }
  46.     }
  47.  
  48.     controllersModule.controller('personController', PersonController);
  49.     controllersModule.controller('companyController', CompanyController);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement