Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Application.Controller {
- import Services = Application.Services;
- var controllersModule = angular.module('controllers', []);
- export interface CompanyScope extends ng.IScope {
- name: string;
- }
- export interface PersonScope extends ng.IScope {
- name: string;
- person: Person;
- }
- type Person = {
- dob: string;
- name: string;
- age?: number;
- }
- class CompanyController {
- static AngularDependency = ['$scope'];
- constructor(private $scope: CompanyScope) {
- this.companyName();
- }
- private companyName() {
- this.$scope.name = "Veripark";
- }
- }
- class PersonController {
- static AngularDependency = ['$scope', 'ageService'];
- ageService: Application.Services.AgeService;
- constructor(private $scope: PersonScope, ageService: Application.Services.AgeService) {
- this.ageService = ageService;
- this.initController();
- }
- private initController() {
- this.$scope.name = 'Berkin';
- this.$scope.person = { name: 'Berkin', dob: '01-01-1995' };
- this.$scope.person.age = this.ageService.calculateAge(this.$scope.person.dob);
- }
- }
- controllersModule.controller('personController', PersonController);
- controllersModule.controller('companyController', CompanyController);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement