Created
October 28, 2013 06:14
-
-
Save evilbloodydemon/7192115 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /// <reference path="_common.ts" /> | |
| module Devices { | |
| export class Device { | |
| constructor( | |
| public ID: number, | |
| public DeviceType: string, | |
| public Vendor: string, | |
| public Model: string, | |
| public Platform: string | |
| ) { } | |
| } | |
| class DevicesListController { | |
| name: string = "Shaitanama"; | |
| devices: Device[] = []; | |
| static $inject = ['$scope', 'devicesService']; | |
| constructor($scope: IScope, devicesService: DevicesService) { | |
| this.devices = devicesService.getList(); | |
| $scope.vm = this; | |
| } | |
| } | |
| class DevicesDetailController { | |
| device: Device; | |
| static $inject = ['$scope', '$routeParams', 'devicesService']; | |
| constructor($scope: IScope, $routeParams, devicesService: DevicesService) { | |
| this.device = devicesService.getByID($routeParams.id); | |
| $scope.vm = this; | |
| } | |
| } | |
| class DevicesService { | |
| static $inject = ['$resource']; | |
| constructor( | |
| public $resource | |
| ) { } | |
| getList(): Device[] { | |
| return this.$resource('/devices', {}, { | |
| query: { | |
| method: 'GET', | |
| isArray: true | |
| } | |
| }).query(); | |
| } | |
| getByID(id: number): Device { | |
| return this.$resource('/devices/view/?id=:id', {}, { | |
| query: { | |
| method: 'GET' | |
| } | |
| }).query({id: id}); | |
| } | |
| } | |
| angular | |
| .module('demoApp.devices', ['ngResource']) | |
| .service('devicesService', DevicesService) | |
| .controller('DevicesListController', DevicesListController) | |
| .controller('DevicesDetailController', DevicesDetailController); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment