Skip to content

Commit

Permalink
Copying javascript files to typescript directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Eggers committed Jan 7, 2014
1 parent 6638dd8 commit c494011
Show file tree
Hide file tree
Showing 15 changed files with 188 additions and 1 deletion.
3 changes: 2 additions & 1 deletion templates/common/root/app/.buildignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.coffee
*.coffee
*.ts
13 changes: 13 additions & 0 deletions templates/typescript/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.otherwise({
redirectTo: '/'
});
})<% } %>;
10 changes: 10 additions & 0 deletions templates/typescript/controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

angular.module('<%= scriptAppName %>')
.controller('<%= classedName %>Ctrl', function ($scope) {
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
});
9 changes: 9 additions & 0 deletions templates/typescript/decorator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

angular.module('<%= scriptAppName %>')
.config(function ($provide) {
$provide.decorator('<%= cameledName %>', function ($delegate) {
// decorate the $delegate
return $delegate;
});
});
12 changes: 12 additions & 0 deletions templates/typescript/directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

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');
}
};
});
8 changes: 8 additions & 0 deletions templates/typescript/filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

angular.module('<%= scriptAppName %>')
.filter('<%= cameledName %>', function () {
return function (input) {
return '<%= cameledName %> filter: ' + input;
};
});
4 changes: 4 additions & 0 deletions templates/typescript/service/constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';

angular.module('<%= scriptAppName %>')
.constant('<%= cameledName %>', 42);
16 changes: 16 additions & 0 deletions templates/typescript/service/factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

angular.module('<%= scriptAppName %>')
.factory('<%= cameledName %>', function () {
// Service logic
// ...

var meaningOfLife = 42;

// Public API here
return {
someMethod: function () {
return meaningOfLife;
}
};
});
25 changes: 25 additions & 0 deletions templates/typescript/service/provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

angular.module('<%= scriptAppName %>')
.provider('<%= cameledName %>', function () {

// Private variables
var salutation = 'Hello';

// 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();
};
});
6 changes: 6 additions & 0 deletions templates/typescript/service/service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

angular.module('<%= scriptAppName %>')
.service('<%= classedName %>', function <%= classedName %>() {
// AngularJS will instantiate a singleton by calling "new" on this function
});
4 changes: 4 additions & 0 deletions templates/typescript/service/value.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';

angular.module('<%= scriptAppName %>')
.value('<%= cameledName %>', 42);
22 changes: 22 additions & 0 deletions templates/typescript/spec/controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

describe('Controller: <%= classedName %>Ctrl', function () {

// load the controller's module
beforeEach(module('<%= scriptAppName %>'));

var <%= classedName %>Ctrl,
scope;

// Initialize the controller and a mock scope
beforeEach(inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
<%= classedName %>Ctrl = $controller('<%= classedName %>Ctrl', {
$scope: scope
});
}));

it('should attach a list of awesomeThings to the scope', function () {
expect(scope.awesomeThings.length).toBe(3);
});
});
20 changes: 20 additions & 0 deletions templates/typescript/spec/directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

describe('Directive: <%= cameledName %>', function () {

// load the directive's module
beforeEach(module('<%= scriptAppName %>'));

var element,
scope;

beforeEach(inject(function ($rootScope) {
scope = $rootScope.$new();
}));

it('should make hidden element visible', inject(function ($compile) {
element = angular.element('<<%= _.dasherize(name) %>></<%= _.dasherize(name) %>>');
element = $compile(element)(scope);
expect(element.text()).toBe('this is the <%= cameledName %> directive');
}));
});
19 changes: 19 additions & 0 deletions templates/typescript/spec/filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

describe('Filter: <%= cameledName %>', function () {

// load the filter's module
beforeEach(module('<%= scriptAppName %>'));

// initialize a new instance of the filter before each test
var <%= cameledName %>;
beforeEach(inject(function ($filter) {
<%= cameledName %> = $filter('<%= cameledName %>');
}));

it('should return the input prefixed with "<%= cameledName %> filter:"', function () {
var text = 'angularjs';
expect(<%= cameledName %>(text)).toBe('<%= cameledName %> filter: ' + text);
});

});
18 changes: 18 additions & 0 deletions templates/typescript/spec/service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

describe('Service: <%= cameledName %>', function () {

// load the service's module
beforeEach(module('<%= scriptAppName %>'));

// instantiate service
var <%= cameledName %>;
beforeEach(inject(function (_<%= cameledName %>_) {
<%= cameledName %> = _<%= cameledName %>_;
}));

it('should do something', function () {
expect(!!<%= cameledName %>).toBe(true);
});

});

0 comments on commit c494011

Please sign in to comment.