-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Adding typescript support to generator-angular #539
Changes from all commits
c494011
f0806c0
8c062da
acf9cff
c7a37fa
3ba295b
3041dd5
96ab8cb
9008eb8
deaf7bd
c79c9b6
1475034
9c9a7dc
a6535ff
fa454bc
f63d6af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
}, | ||
"devDependencies": { | ||
"angular-mocks": "1.2.6", | ||
"angular-scenario": "1.2.6" | ||
"angular-scenario": "1.2.6"<% if (typescript) { %>, | ||
"dt-jasmine": "~2.0.0", | ||
"dt-angular": "https://github.com/jedmao/dt-angular/archive/v1.2.0.tar.gz"<% } %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we switch the placement of these two so they are listed alphabetically? I find it's sometimes hard to find what I'm looking for in these manifest files when they aren't alphabetical. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.coffee | ||
*.coffee | ||
*.ts |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/// <reference path="../bower_components/dt-angular/angular.d.ts" /><% if (ngCookies) { %> | ||
/// <reference path="../bower_components/dt-angular/angular-cookies.d.ts" /><% } %><% if (ngResource) { %> | ||
/// <reference path="../bower_components/dt-angular/angular-resource.d.ts" /><% } %><% if (ngSanitize) { %> | ||
/// <reference path="../bower_components/dt-angular/angular-sanitize.d.ts" /><% } %><% if (ngRoute) { %> | ||
/// <reference path="../bower_components/dt-angular/angular-route.d.ts" /><% } %> | ||
|
||
'use strict'; | ||
|
||
angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %> | ||
.config(($routeProvider:ng.route.IRouteProvider) => { | ||
$routeProvider | ||
.when('/', { | ||
templateUrl: 'views/main.html', | ||
controller: 'MainCtrl' | ||
}) | ||
.otherwise({ | ||
redirectTo: '/' | ||
}); | ||
})<% } %>; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/// <reference path="../app.ts" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about the installed Angular modules. Do they not need to be referenced up here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see what you did there. Since app.ts is referenced, you don't need to re-reference any of the angular modules. Nice! |
||
|
||
'use strict'; | ||
|
||
module <%= scriptAppName %> { | ||
export interface I<%= classedName %>Scope extends ng.IScope { | ||
awesomeThings: any[]; | ||
} | ||
|
||
export class <%= classedName %>Ctrl { | ||
|
||
constructor (private $scope: I<%= classedName %>Scope) { | ||
$scope.awesomeThings = [ | ||
'HTML5 Boilerplate', | ||
'AngularJS', | ||
'Karma' | ||
]; | ||
} | ||
} | ||
} | ||
|
||
angular.module('<%= scriptAppName %>') | ||
.controller('<%= classedName %>Ctrl', <%= scriptAppName %>.<%= classedName %>Ctrl); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// <reference path="../app.ts" /> | ||
|
||
'use strict'; | ||
|
||
module <%= scriptAppName %> { | ||
export function <%= cameledName %>DecoratorProvider($provide: ng.auto.IProvideService): void { | ||
//decorate <%= cameledName %> | ||
$provide.decorator('<%= cameledName %>', <%= cameledName %>Decorator); | ||
} | ||
|
||
export function <%= cameledName %>Decorator($delegate: any) { | ||
// decorate the $delegate | ||
return $delegate; | ||
} | ||
} | ||
|
||
angular.module('<%= scriptAppName %>') | ||
.config(<%= scriptAppName %>.<%= cameledName %>DecoratorProvider); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/// <reference path="../app.ts" /> | ||
|
||
'use strict'; | ||
|
||
module <%= scriptAppName %> { | ||
|
||
export class <%= classedName %> implements ng.IDirective { | ||
template = '<div></div>'; | ||
restrict = 'E'; | ||
link = (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes): void => { | ||
element.text('this is the <%= cameledName %> directive'); | ||
} | ||
} | ||
|
||
export function <%= cameledName %>Factory() { | ||
return new <%= scriptAppName %>.<%= classedName %>(); | ||
} | ||
|
||
} | ||
|
||
angular.module('<%= scriptAppName %>') | ||
.directive('<%= cameledName %>', <%= scriptAppName %>.<%= cameledName %>Factory); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// <reference path="../app.ts" /> | ||
|
||
'use strict'; | ||
|
||
module <%= scriptAppName %> { | ||
export function <%= cameledName %>FilterFactory(): Function { | ||
return <%= cameledName %>Filter; | ||
} | ||
|
||
function <%= cameledName %>Filter(input, param) { | ||
//usage {{"text" | <%= cameledName %>: "suffix"}} | ||
//returns '<%= cameledName %> filter: text suffix' | ||
return '<%= cameledName %> filter: ' + input + (param ? ' ' + param: ''); | ||
} | ||
} | ||
|
||
angular.module('<%= scriptAppName %>') | ||
.filter('<%= cameledName %>', <%= scriptAppName %>.<%= cameledName %>FilterFactory); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/// <reference path="../app.ts" /> | ||
|
||
'use strict'; | ||
|
||
angular.module('<%= scriptAppName %>') | ||
.constant('<%= cameledName %>', 42); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure the splicable section doesn't also need a condition for typescript? Maybe (coffee || typescript)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, because typescript is a superset of javascript, so it has the same syntax as javascript. CoffeeScript has different language syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Just making sure.