Skip to content

Commit

Permalink
Update Typescript AngularJS templates updated to be Typescript 1.0 an…
Browse files Browse the repository at this point in the history
…d Angular 1.3 compatible

*  Controller templates:  changed to be implemented as functions rather
than classes; removed controllerId variable
*  Factory Template:  serviceId variable was removed from the interface
definition, since it is a static member of the class
*  Directive Template:  directiveId variable was removed from the
interface definition, since it is a static member of the class
  • Loading branch information
RobHudson72 committed Feb 15, 2015
1 parent aeb1093 commit 3498aee
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,14 @@ interface I$safeitemname$Scope extends ng.IScope {
changeGreeting: () => void;
}

interface I$safeitemname$ {
controllerId: string;
}

class $safeitemname$ implements I$safeitemname$ {
static controllerId: string = "$safeitemname$";

constructor(private $scope: I$safeitemname$Scope, private $http: ng.IHttpService, private $resource: ng.resource.IResourceService) {
$scope.greeting = "Hello";
$scope.changeGreeting = () => this.changeGreeting();
}

private changeGreeting() {
this.$scope.greeting = "Bye";
}
function $safeitemname$($scope: I$safeitemname$Scope, $http: ng.IHttpService, $resource: ng.resource.IResourceService) {
$scope.greeting = "Hello";
$scope.changeGreeting = (): void => {
$scope.greeting = "Bye";
};
}

// Update the app1 variable name to be that of your module variable
app1.controller($safeitemname$.controllerId, ['$scope', '$http', '$resource', ($scope, $http, $resource) =>
new $safeitemname$($scope, $http, $resource)
app1.controller("$safeitemname$", ['$scope', '$http', '$resource',
$safeitemname$
]);
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,22 @@
/// <reference path='/Scripts/typings/angularjs/angular.d.ts'/>
/// <reference path='/Scripts/typings/angularjs/angular-resource.d.ts'/>

interface I$safeitemname$Scope extends ng.IScope {
vm: $safeitemname$;
}

interface I$safeitemname$ {
greeting: string;
controllerId: string;
changeGreeting: () => void;
}

class $safeitemname$ implements I$safeitemname$ {
static controllerId: string = "$safeitemname$";
greeting = "Hello";

constructor(private $scope: I$safeitemname$Scope, private $http: ng.IHttpService, private $resource: ng.resource.IResourceService) {
}
function $safeitemname$($scope: ng.IScope, $http: ng.IHttpService, $resource: ng.resource.IResourceService){
var vm: I$safeitemname$ = this;
vm.greeting = "Hello";

changeGreeting() {
this.greeting = "Bye";
vm.changeGreeting=(): void =>{
vm.greeting = "Bye";
}
}


// Update the app1 variable name to be that of your module variable
app1.controller($safeitemname$.controllerId, ['$scope', '$http', '$resource', ($scope, $http, $resource) =>
new $safeitemname$($scope, $http, $resource)
app1.controller("$safeitemname$", ['$scope', '$http', '$resource',
$safeitemname$
]);
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
/// <reference path='/Scripts/typings/angularjs/angular-resource.d.ts'/>

interface I$safeitemname$ extends ng.IDirective {
directiveId: string;
}

interface I$safeitemname$Scope extends ng.IScope {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

interface I$safeitemname$ {
greeting: string;
serviceId: string;
changeGreeting: () => void;
}

Expand Down

0 comments on commit 3498aee

Please sign in to comment.