Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Web/Scripts/Chutzpah.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"Framework": "jasmine",
"TypeScriptCodeGenTarget": "ES5",
"CodeCoverageExcludes": [
"*\\vendor\\*.js",
"controllersSpec.js",
],
"References": [
{ "Path": "vendor\\angular.min.js" },
{ "Path": "vendor\\angular-mocks.js" },
{ "Path": "typings\\jquery\\jquery.d.ts", "IncludeInTestHarness": false },
{ "Path": "typings\\angularjs\\angular.d.ts", "IncludeInTestHarness": false },
{ "Path": "typings\\angularjs\\angular-mocks.d.ts", "IncludeInTestHarness": false },
{ "Path": "typings\\jasmine\\jasmine.d.ts", "IncludeInTestHarness": false }
]
}
11 changes: 0 additions & 11 deletions src/Web/Scripts/_references.js

This file was deleted.

1 change: 1 addition & 0 deletions src/Web/Scripts/_references.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference path="typings/angularjs/angular.d.ts" />
15 changes: 10 additions & 5 deletions src/Web/Scripts/app.js → src/Web/Scripts/app.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
'use strict';
'use strict';

interface IAppRootScopeService extends ng.IRootScopeService {
$state: any;
$stateParams: any;
layout: string;
}

// Declares how the application should be bootstrapped. See: http://docs.angularjs.org/guide/module
angular.module('app', ['ui.router', 'app.filters', 'app.services', 'app.directives', 'app.controllers'])

// Gets executed during the provider registrations and configuration phase. Only providers and constants can be
// injected here. This is to prevent accidental instantiation of services before they have been fully configured.
.config(['$stateProvider', '$locationProvider', function ($stateProvider, $locationProvider) {
.config(['$stateProvider', '$locationProvider', function ($stateProvider, $locationProvider : ng.ILocationProvider) {

// UI States, URL Routing & Mapping. For more info see: https://github.com/angular-ui/ui-router
// ------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -40,7 +46,7 @@ angular.module('app', ['ui.router', 'app.filters', 'app.services', 'app.directiv

// Gets executed after the injector is created and are used to kickstart the application. Only instances and constants
// can be injected here. This is to prevent further system configuration during application run time.
.run(['$templateCache', '$rootScope', '$state', '$stateParams', function ($templateCache, $rootScope, $state, $stateParams) {
.run(['$templateCache', '$rootScope', '$state', '$stateParams', function ($templateCache: ng.ITemplateCacheService, $rootScope: IAppRootScopeService, $state, $stateParams) {

// <ui-view> contains a pre-rendered template for the current view
// caching it will prevent a round-trip to a server at the first page load
Expand All @@ -50,8 +56,7 @@ angular.module('app', ['ui.router', 'app.filters', 'app.services', 'app.directiv
// Allows to retrieve UI Router state information from inside templates
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;

$rootScope.$on('$stateChangeSuccess', function (event, toState) {
$rootScope.$on('$stateChangeSuccess', (event, toState?): any => {

// Sets the layout name, which can be used to display different layouts (header, footer etc.)
// based on which page the user is located
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
'use strict';
'use strict';

// Google Analytics Collection APIs Reference:
// https://developers.google.com/analytics/devguides/collection/analyticsjs/

angular.module('app.controllers', [])

// Path: /
.controller('HomeCtrl', ['$scope', '$location', '$window', function ($scope, $location, $window) {
.controller('HomeCtrl', ['$scope', '$location', '$window', ($scope, $location, $window) => {
$scope.$root.title = 'AngularJS SPA Template for Visual Studio';
$scope.$on('$viewContentLoaded', function () {
$scope.$on('$viewContentLoaded', () => {
$window.ga('send', 'pageview', { 'page': $location.path(), 'title': $scope.$root.title });
});
}])

// Path: /about
.controller('AboutCtrl', ['$scope', '$location', '$window', function ($scope, $location, $window) {
.controller('AboutCtrl', ['$scope', '$location', '$window', ($scope, $location, $window) => {
$scope.$root.title = 'AngularJS SPA | About';
$scope.$on('$viewContentLoaded', function () {
$scope.$on('$viewContentLoaded', () => {
$window.ga('send', 'pageview', { 'page': $location.path(), 'title': $scope.$root.title });
});
}])

// Path: /login
.controller('LoginCtrl', ['$scope', '$location', '$window', function ($scope, $location, $window) {
.controller('LoginCtrl', ['$scope', '$location', '$window', ($scope, $location, $window) => {
$scope.$root.title = 'AngularJS SPA | Sign In';
// TODO: Authorize a user
$scope.login = function () {
$location.path('/');
return false;
};
$scope.$on('$viewContentLoaded', function () {
$scope.$on('$viewContentLoaded', () => {
$window.ga('send', 'pageview', { 'page': $location.path(), 'title': $scope.$root.title });
});
}])

// Path: /error/404
.controller('Error404Ctrl', ['$scope', '$location', '$window', function ($scope, $location, $window) {
.controller('Error404Ctrl', ['$scope', '$location', '$window', ($scope, $location, $window) => {
$scope.$root.title = 'Error 404: Page Not Found';
$scope.$on('$viewContentLoaded', function () {
$scope.$on('$viewContentLoaded', () => {
$window.ga('send', 'pageview', { 'page': $location.path(), 'title': $scope.$root.title });
});
}]);
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference path="_references.js" />
/// <reference path="controllers.js" />
/// <reference path="controllers.ts" />

'use strict';

Expand Down
9 changes: 0 additions & 9 deletions src/Web/Scripts/directives.js

This file was deleted.

20 changes: 0 additions & 20 deletions src/Web/Scripts/directives.spec.js

This file was deleted.

9 changes: 9 additions & 0 deletions src/Web/Scripts/directives.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

angular.module('app.directives', [])

.directive('appVersion', ['version', (version : string) => {
return (scope, elm, attrs) => {
elm.text(version);
};
}]);
19 changes: 19 additions & 0 deletions src/Web/Scripts/directivesSpec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// <reference path="directives.ts" />

'use strict';

describe('Directives', () => {
beforeEach(module('app.directives'));

describe('app-version', () => {
it('should print current version', () => {
module(($provide) => {
$provide.value('version', 'TEST_VER');
});
inject(($compile, $rootScope) => {
var element = $compile('<span app-version></span>')($rootScope);
expect(element.text()).toEqual('TEST_VER');
});
});
});
});
18 changes: 0 additions & 18 deletions src/Web/Scripts/filters.spec.js

This file was deleted.

6 changes: 3 additions & 3 deletions src/Web/Scripts/filters.js → src/Web/Scripts/filters.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';
'use strict';

angular.module('app.filters', [])

.filter('interpolate', ['version', function (version) {
return function (text) {
.filter('interpolate', ['version', (version) => {
return (text) => {
return String(text).replace(/\%VERSION\%/mg, version);
}
}]);
17 changes: 17 additions & 0 deletions src/Web/Scripts/filtersSpec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// <reference path="filters.ts" />

'use strict';

describe('Filters', () => {
beforeEach(module('app.filters'));

describe('interpolate', () => {
beforeEach(module(($provide) => {
$provide.value('version', 'TEST_VER');
}));

it('should replace VERSION', inject((interpolateFilter) => {
expect(interpolateFilter('before %VERSION% after')).toEqual('before TEST_VER after');
}));
});
});
14 changes: 0 additions & 14 deletions src/Web/Scripts/services.spec.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/Web/Scripts/services.js → src/Web/Scripts/services.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
'use strict';

// Demonstrate how to register services
// In this case it is a simple value service.
angular.module('app.services', [])

.value('version', '0.1');
.value('version', '1.0.0');
13 changes: 13 additions & 0 deletions src/Web/Scripts/servicesSpec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// <reference path="services.ts" />

'use strict';

describe('Services', () => {
beforeEach(module('app.services'));

describe('version', () => {
it('should return current version', inject((version) => {
expect(version).toEqual('1.0.0');
}));
});
});
30 changes: 30 additions & 0 deletions src/Web/Scripts/typings/angularjs/angular-cookies.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// Type definitions for Angular JS 1.2 (ngCookies module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar <http://github.com/diegovilar>
// Definitions: https://github.com/borisyankov/DefinitelyTyped


/// <reference path="angular.d.ts" />

///////////////////////////////////////////////////////////////////////////////
// ngCookies module (angular-cookies.js)
///////////////////////////////////////////////////////////////////////////////
declare module ng.cookies {

///////////////////////////////////////////////////////////////////////////
// CookieService
// see http://docs.angularjs.org/api/ngCookies.$cookies
///////////////////////////////////////////////////////////////////////////
interface ICookiesService {}

///////////////////////////////////////////////////////////////////////////
// CookieStoreService
// see http://docs.angularjs.org/api/ngCookies.$cookieStore
///////////////////////////////////////////////////////////////////////////
interface ICookieStoreService {
get(key: string): any;
put(key: string, value: any): void;
remove(key: string): void;
}

}
Loading