forked from yeoman/generator-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jacob Eggers
committed
Jan 7, 2014
1 parent
acf9cff
commit c7a37fa
Showing
8 changed files
with
125 additions
and
62 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
/// <reference path="../app.ts" /> | ||
|
||
'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', function ($scope) { | ||
$scope.awesomeThings = [ | ||
'HTML5 Boilerplate', | ||
'AngularJS', | ||
'Karma' | ||
]; | ||
}); | ||
.controller('<%= classedName %>Ctrl', <%= scriptAppName %>.<%= classedName %>Ctrl); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +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) { | ||
// decorate the $delegate | ||
return $delegate; | ||
} | ||
} | ||
|
||
angular.module('<%= scriptAppName %>') | ||
.config(function ($provide) { | ||
$provide.decorator('<%= cameledName %>', function ($delegate) { | ||
// decorate the $delegate | ||
return $delegate; | ||
}); | ||
}); | ||
.config(<%= scriptAppName %>.<%= cameledName %>DecoratorProvider); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
/// <reference path="../app.ts" /> | ||
|
||
'use strict'; | ||
|
||
module <%= scriptAppName %> { | ||
|
||
export class <%= classedName %> implements ng.IDirective { | ||
template = '<div></div>'; | ||
restrict = 'E'; | ||
link = function (scope, element: JQuery, attrs: ng.IAttributes):void { | ||
element.text('this is the <%= cameledName %> directive'); | ||
} | ||
} | ||
|
||
export function <%= cameledName %>Factory() { | ||
return new <%= scriptAppName %>.<%= classedName %>(); | ||
} | ||
|
||
} | ||
|
||
angular.module('<%= scriptAppName %>') | ||
.directive('<%= cameledName %>', function () { | ||
return { | ||
template: '<div></div>', | ||
restrict: 'E', | ||
link: function postLink(scope, element, attrs) { | ||
element.text('this is the <%= cameledName %> directive'); | ||
} | ||
}; | ||
}); | ||
.directive('<%= cameledName %>', <%= scriptAppName %>.<%= cameledName %>Factory); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +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 %>', function () { | ||
return function (input) { | ||
return '<%= cameledName %> filter: ' + input; | ||
}; | ||
}); | ||
.filter('<%= cameledName %>', <%= scriptAppName %>.<%= cameledName %>FilterFactory); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
/// <reference path="../app.ts" /> | ||
|
||
'use strict'; | ||
|
||
angular.module('<%= scriptAppName %>') | ||
.factory('<%= cameledName %>', function () { | ||
// Service logic | ||
// ... | ||
module <%= scriptAppName %> { | ||
export function <%= cameledName %>Factory() { | ||
return new <%= classedName %>(42); | ||
} | ||
export class <%= classedName %> { | ||
|
||
var meaningOfLife = 42; | ||
constructor (private meaningOfLife) { | ||
} | ||
|
||
// Public API here | ||
return { | ||
someMethod: function () { | ||
return meaningOfLife; | ||
} | ||
}; | ||
}); | ||
someMethod(){ | ||
return this.meaningOfLife | ||
} | ||
} | ||
} | ||
|
||
angular.module('<%= scriptAppName %>') | ||
.factory('<%= cameledName %>', <%= scriptAppName %>.<%= cameledName %>Factory); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
/// <reference path="../app.ts" /> | ||
|
||
'use strict'; | ||
|
||
angular.module('<%= scriptAppName %>') | ||
.provider('<%= cameledName %>', function () { | ||
module <%= scriptAppName %> { | ||
|
||
// Private variables | ||
var salutation = 'Hello'; | ||
var salutation:string; | ||
|
||
export class Greeter { | ||
greet = () => salutation; | ||
} | ||
|
||
|
||
export class <%= classedName %>Provider { | ||
$get = () => new Greeter(); | ||
|
||
// Public API for configuration | ||
setSalutation = (s:string) => salutation = s; | ||
} | ||
|
||
// Private constructor | ||
function Greeter() { | ||
this.greet = function () { | ||
return salutation; | ||
}; | ||
} | ||
} | ||
|
||
// Public API for configuration | ||
this.setSalutation = function (s) { | ||
salutation = s; | ||
}; | ||
|
||
// Method for instantiating | ||
this.$get = function () { | ||
return new Greeter(); | ||
}; | ||
}); | ||
angular.module('<%= scriptAppName %>') | ||
.provider('<%= cameledName %>', <%= scriptAppName %>.<%= classedName %>Provider); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
/// <reference path="../app.ts" /> | ||
|
||
'use strict'; | ||
|
||
module <%= scriptAppName %> { | ||
export class <%= classedName %> { | ||
awesomeThings:any[] = [ | ||
'HTML5 Boilerplate', | ||
'AngularJS', | ||
'Karma' | ||
]; | ||
} | ||
} | ||
|
||
angular.module('<%= scriptAppName %>') | ||
.service('<%= classedName %>', function <%= classedName %>() { | ||
// AngularJS will instantiate a singleton by calling "new" on this function | ||
}); | ||
.service('<%= cameledName %>', <%= scriptAppName %>.<%= classedName %>); |