diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/css/animations.css b/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.animations.css
similarity index 100%
rename from public/docs/_examples/upgrade-phonecat/ts/classes/app/css/animations.css
rename to public/docs/_examples/upgrade-phonecat/ts/classes/app/app.animations.css
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.config.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.config.ts
new file mode 100644
index 0000000000..9b99261074
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.config.ts
@@ -0,0 +1,12 @@
+// #docregion
+export default ['$routeProvider',
+ function config($routeProvider) {
+ $routeProvider.
+ when('/phones', {
+ template: ''
+ }).
+ when('/phones/:phoneId', {
+ template: ''
+ }).
+ otherwise('/phones');
+}];
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/css/app.css b/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.css
similarity index 100%
rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/css/app.css
rename to public/docs/_examples/upgrade-phonecat/ts/classes/app/app.css
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.module.ts
new file mode 100644
index 0000000000..d4e0e8b25c
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/app.module.ts
@@ -0,0 +1,18 @@
+// #docregion pre-bootstrap
+import core from './core/core.module';
+import phoneList from './phone-list/phone-list.module';
+import phoneDetail from './phone-detail/phone-detail.module';
+import appConfig from './app.config';
+
+angular.module('phonecatApp', [
+ 'ngAnimate',
+ 'ngRoute',
+ core.name,
+ phoneList.name,
+ phoneDetail.name
+]).config(appConfig);
+
+// #enddocregion pre-bootstrap
+// #docregion bootstrap
+angular.bootstrap(document.documentElement, ['phonecatApp']);
+// #enddocregion bootstrap
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/checkmark.filter.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/checkmark/checkmark.filter.spec.ts
similarity index 76%
rename from public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/checkmark.filter.spec.ts
rename to public/docs/_examples/upgrade-phonecat/ts/classes/app/core/checkmark/checkmark.filter.spec.ts
index bae35e6875..6704c74999 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/checkmark.filter.spec.ts
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/checkmark/checkmark.filter.spec.ts
@@ -1,10 +1,10 @@
// #docregion top
-import '../../app/js/core/core.module';
+import '../core.module';
// #enddocregion top
describe('checkmarkFilter', function() {
- beforeEach(angular.mock.module('phonecat.core'));
+ beforeEach(angular.mock.module('core'));
it('should convert boolean values to unicode checkmark or cross',
inject(function(checkmarkFilter) {
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/checkmark.filter.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/checkmark/checkmark.filter.ts
similarity index 100%
rename from public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/checkmark.filter.ts
rename to public/docs/_examples/upgrade-phonecat/ts/classes/app/core/checkmark/checkmark.filter.ts
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/core.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/core.module.ts
new file mode 100644
index 0000000000..041f56ea79
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/core.module.ts
@@ -0,0 +1,6 @@
+// #docregion
+import checkmarkFilter from './checkmark/checkmark.filter';
+import phone from './phone/phone.module';
+
+export default angular.module('core', [phone.name])
+ .filter('checkmark', checkmarkFilter);
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.module.ts
new file mode 100644
index 0000000000..d60c3c9a07
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.module.ts
@@ -0,0 +1,5 @@
+// #docregion
+import Phone from './phone.service';
+
+export default angular.module('core.phone', ['ngResource'])
+ .factory('Phone', Phone);
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.service.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.service.spec.ts
new file mode 100644
index 0000000000..269ce500e9
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.service.spec.ts
@@ -0,0 +1,47 @@
+// #docregion top
+import './phone.module';
+// #enddocregion top
+
+'use strict';
+
+describe('Phone', function() {
+ var $httpBackend;
+ var Phone;
+ var phonesData = [
+ {name: 'Phone X'},
+ {name: 'Phone Y'},
+ {name: 'Phone Z'}
+ ];
+
+ // Add a custom equality tester before each test
+ beforeEach(function() {
+ jasmine.addCustomEqualityTester(angular.equals);
+ });
+
+ // Load the module that contains the `Phone` service before each test
+ beforeEach(angular.mock.module('core.phone'));
+
+ // Instantiate the service and "train" `$httpBackend` before each test
+ beforeEach(inject(function(_$httpBackend_, _Phone_) {
+ $httpBackend = _$httpBackend_;
+ $httpBackend.expectGET('phones/phones.json').respond(phonesData);
+
+ Phone = _Phone_;
+ }));
+
+ // Verify that there are no outstanding expectations or requests after each test
+ afterEach(function () {
+ $httpBackend.verifyNoOutstandingExpectation();
+ $httpBackend.verifyNoOutstandingRequest();
+ });
+
+ it('should fetch the phones data from `/phones/phones.json`', function() {
+ var phones = Phone.query();
+
+ expect(phones).toEqual([]);
+
+ $httpBackend.flush();
+ expect(phones).toEqual(phonesData);
+ });
+
+});
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.service.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.service.ts
new file mode 100644
index 0000000000..861ff78832
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/core/phone/phone.service.ts
@@ -0,0 +1,12 @@
+// #docregion
+export default ['$resource',
+ function Phone($resource) {
+ return $resource('phones/:phoneId.json', {}, {
+ query: {
+ method: 'GET',
+ params: {phoneId: 'phones'},
+ isArray: true
+ }
+ });
+ }
+];
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/css/.gitkeep b/public/docs/_examples/upgrade-phonecat/ts/classes/app/css/.gitkeep
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/index.html b/public/docs/_examples/upgrade-phonecat/ts/classes/app/index.html
index db01afac1c..096a0ef1bd 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/index.html
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/index.html
@@ -4,8 +4,8 @@
Google Phone Gallery
-
-
+
+
@@ -15,7 +15,7 @@
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/app.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/app.module.ts
deleted file mode 100644
index 01e3328c1e..0000000000
--- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/app.module.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-// #docregion pre-bootstrap
-
-import core from './core/core.module';
-import phoneList from './phone_list/phone_list.module';
-import phoneDetail from './phone_detail/phone_detail.module';
-
-angular.module('phonecatApp', [
- 'ngRoute',
- core.name,
- phoneList.name,
- phoneDetail.name
-]).config(configure);
-
-configure.$inject = ['$routeProvider'];
-
-function configure($routeProvider) {
- $routeProvider.
- when('/phones', {
- templateUrl: 'js/phone_list/phone_list.html',
- controller: 'PhoneListCtrl',
- controllerAs: 'vm'
- }).
- when('/phones/:phoneId', {
- templateUrl: 'js/phone_detail/phone_detail.html',
- controller: 'PhoneDetailCtrl',
- controllerAs: 'vm'
- }).
- otherwise({
- redirectTo: '/phones'
- });
-}
-// #enddocregion pre-bootstrap
-// #docregion bootstrap
-angular.bootstrap(document.documentElement, ['phonecatApp']);
-// #enddocregion bootstrap
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/core.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/core.module.ts
deleted file mode 100644
index c20ce33683..0000000000
--- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/core.module.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-// #docregion
-import Phone from './phone.factory';
-import checkmarkFilter from './checkmark.filter';
-
-export default angular.module('phonecat.core', [
- 'ngResource'
- ])
- .factory('Phone', Phone)
- .filter('checkmark', checkmarkFilter);
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/phone.factory.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/phone.factory.ts
deleted file mode 100644
index a8492b29fc..0000000000
--- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/phone.factory.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-// #docregion
-Phone.$inject = ['$resource'];
-
-function Phone($resource) {
- return $resource('phones/:phoneId.json', {}, {
- query: {method:'GET', params:{phoneId:'phones'}, isArray:true}
- });
-}
-
-export default Phone;
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.controller.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.controller.ts
deleted file mode 100644
index c5b96b6f08..0000000000
--- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.controller.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-// #docregion
-interface PhoneRouteParams {
- phoneId: string
-}
-
-class PhoneDetailCtrl {
- phone:any;
- mainImageUrl:string;
- constructor($routeParams:PhoneRouteParams, Phone) {
- this.phone = Phone.get({phoneId: $routeParams.phoneId}, (phone) =>
- this.mainImageUrl = phone.images[0]
- );
- }
-
- setImage(url:string) {
- this.mainImageUrl = url;
- }
-}
-
-PhoneDetailCtrl.$inject = ['$routeParams', 'Phone'];
-
-export default PhoneDetailCtrl;
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.html b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.html
deleted file mode 100644
index 954c65c2cd..0000000000
--- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.html
+++ /dev/null
@@ -1,118 +0,0 @@
-
-
![]()
-
-
-{{vm.phone.name}}
-
-{{vm.phone.description}}
-
-
- -
-
-
-
-
-
- -
- Availability and Networks
-
- - Availability
- - {{availability}}
-
-
- -
- Battery
-
- - Type
- - {{vm.phone.battery.type}}
- - Talk Time
- - {{vm.phone.battery.talkTime}}
- - Standby time (max)
- - {{vm.phone.battery.standbyTime}}
-
-
- -
- Storage and Memory
-
- - RAM
- - {{vm.phone.storage.ram}}
- - Internal Storage
- - {{vm.phone.storage.flash}}
-
-
- -
- Connectivity
-
- - Network Support
- - {{vm.phone.connectivity.cell}}
- - WiFi
- - {{vm.phone.connectivity.wifi}}
- - Bluetooth
- - {{vm.phone.connectivity.bluetooth}}
- - Infrared
- - {{vm.phone.connectivity.infrared | checkmark}}
- - GPS
- - {{vm.phone.connectivity.gps | checkmark}}
-
-
- -
- Android
-
- - OS Version
- - {{vm.phone.android.os}}
- - UI
- - {{vm.phone.android.ui}}
-
-
- -
- Size and Weight
-
- - Dimensions
- - {{dim}}
- - Weight
- - {{vm.phone.sizeAndWeight.weight}}
-
-
- -
- Display
-
- - Screen size
- - {{vm.phone.display.screenSize}}
- - Screen resolution
- - {{vm.phone.display.screenResolution}}
- - Touch screen
- - {{vm.phone.display.touchScreen | checkmark}}
-
-
- -
- Hardware
-
- - CPU
- - {{vm.phone.hardware.cpu}}
- - USB
- - {{vm.phone.hardware.usb}}
- - Audio / headphone jack
- - {{vm.phone.hardware.audioJack}}
- - FM Radio
- - {{vm.phone.hardware.fmRadio | checkmark}}
- - Accelerometer
- - {{vm.phone.hardware.accelerometer | checkmark}}
-
-
- -
- Camera
-
- - Primary
- - {{vm.phone.camera.primary}}
- - Features
- - {{vm.phone.camera.features.join(', ')}}
-
-
- -
- Additional Features
-
- {{vm.phone.additionalFeatures}}
-
-
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.module.ts
deleted file mode 100644
index 16e7ac0baf..0000000000
--- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.module.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-// #docregion
-import PhoneDetailCtrl from './phone_detail.controller';
-
-export default angular.module('phonecat.detail', [
- 'ngRoute',
- 'phonecat.core'
- ])
- .controller('PhoneDetailCtrl', PhoneDetailCtrl);
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.controller.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.controller.ts
deleted file mode 100644
index f1a5beb808..0000000000
--- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.controller.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-// #docregion
-class PhoneListCtrl {
- phones:any[];
- orderProp:string;
- query:string;
- constructor(Phone) {
- this.phones = Phone.query();
- this.orderProp = 'age';
- }
-}
-
-PhoneListCtrl.$inject = ['Phone'];
-
-export default PhoneListCtrl;
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.module.ts
deleted file mode 100644
index 758b937927..0000000000
--- a/public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.module.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-// #docregion
-import PhoneListCtrl from './phone_list.controller';
-
-export default angular.module('phonecat.list', ['phonecat.core'])
- .controller('PhoneListCtrl', PhoneListCtrl);
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.component.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.component.spec.ts
new file mode 100644
index 0000000000..4d0b3c0cb7
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.component.spec.ts
@@ -0,0 +1,38 @@
+// #docregion top
+import './phone-detail.module';
+// #enddocregion top
+
+describe('phoneDetail', function(){
+
+ // Load the module that contains the `phoneDetail` component before each test
+ beforeEach(angular.mock.module('phoneDetail'));
+
+ // Test the controller
+ describe('PhoneDetailController', function() {
+ var $httpBackend, ctrl;
+ var xyzPhoneData = {
+ name: 'phone xyz',
+ images: ['image/url1.png', 'image/url2.png']
+ };
+
+ beforeEach(inject(function($componentController, _$httpBackend_, $routeParams) {
+ $httpBackend = _$httpBackend_;
+ $httpBackend.expectGET('phones/xyz.json').respond(xyzPhoneData);
+
+ $routeParams.phoneId = 'xyz';
+
+ ctrl = $componentController('phoneDetail', {$scope: {}});
+ }));
+
+ it('should fetch the phone details', function() {
+ jasmine.addCustomEqualityTester(angular.equals);
+
+ expect(ctrl.phone).toEqual({});
+
+ $httpBackend.flush();
+ expect(ctrl.phone).toEqual(xyzPhoneData);
+ });
+
+ });
+
+});
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.component.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.component.ts
new file mode 100644
index 0000000000..5e3a35a3d4
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.component.ts
@@ -0,0 +1,26 @@
+// #docregion
+interface PhoneRouteParams {
+ phoneId: string
+}
+
+class PhoneDetailController {
+ phone:any;
+ mainImageUrl:string;
+
+ static $inject = ['$routeParams', 'Phone'];
+ constructor($routeParams:PhoneRouteParams, Phone) {
+ this.phone = Phone.get({phoneId: $routeParams.phoneId}, phone => {
+ this.setImage(phone.images[0]);
+ });
+ }
+
+ setImage(imageUrl) {
+ this.mainImageUrl = imageUrl;
+ }
+
+}
+
+export default {
+ templateUrl: 'phone-detail/phone-detail.template.html',
+ controller: PhoneDetailController
+};
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.module.ts
new file mode 100644
index 0000000000..d9e95c0761
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.module.ts
@@ -0,0 +1,9 @@
+// #docregion
+import phoneDetail from './phone-detail.component';
+import phone from '../core/phone/phone.module';
+
+export default angular.module('phoneDetail', [
+ 'ngRoute',
+ phone.name
+ ])
+ .component('phoneDetail', phoneDetail);
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.template.html b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.template.html
new file mode 100644
index 0000000000..019ccf45c7
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-detail/phone-detail.template.html
@@ -0,0 +1,118 @@
+
+
![]()
+
+
+{{$ctrl.phone.name}}
+
+{{$ctrl.phone.description}}
+
+
+ -
+
+
+
+
+
+ -
+ Availability and Networks
+
+ - Availability
+ - {{availability}}
+
+
+ -
+ Battery
+
+ - Type
+ - {{$ctrl.phone.battery.type}}
+ - Talk Time
+ - {{$ctrl.phone.battery.talkTime}}
+ - Standby time (max)
+ - {{$ctrl.phone.battery.standbyTime}}
+
+
+ -
+ Storage and Memory
+
+ - RAM
+ - {{$ctrl.phone.storage.ram}}
+ - Internal Storage
+ - {{$ctrl.phone.storage.flash}}
+
+
+ -
+ Connectivity
+
+ - Network Support
+ - {{$ctrl.phone.connectivity.cell}}
+ - WiFi
+ - {{$ctrl.phone.connectivity.wifi}}
+ - Bluetooth
+ - {{$ctrl.phone.connectivity.bluetooth}}
+ - Infrared
+ - {{$ctrl.phone.connectivity.infrared | checkmark}}
+ - GPS
+ - {{$ctrl.phone.connectivity.gps | checkmark}}
+
+
+ -
+ Android
+
+ - OS Version
+ - {{$ctrl.phone.android.os}}
+ - UI
+ - {{$ctrl.phone.android.ui}}
+
+
+ -
+ Size and Weight
+
+ - Dimensions
+ - {{dim}}
+ - Weight
+ - {{$ctrl.phone.sizeAndWeight.weight}}
+
+
+ -
+ Display
+
+ - Screen size
+ - {{$ctrl.phone.display.screenSize}}
+ - Screen resolution
+ - {{$ctrl.phone.display.screenResolution}}
+ - Touch screen
+ - {{$ctrl.phone.display.touchScreen | checkmark}}
+
+
+ -
+ Hardware
+
+ - CPU
+ - {{$ctrl.phone.hardware.cpu}}
+ - USB
+ - {{$ctrl.phone.hardware.usb}}
+ - Audio / headphone jack
+ - {{$ctrl.phone.hardware.audioJack}}
+ - FM Radio
+ - {{$ctrl.phone.hardware.fmRadio | checkmark}}
+ - Accelerometer
+ - {{$ctrl.phone.hardware.accelerometer | checkmark}}
+
+
+ -
+ Camera
+
+ - Primary
+ - {{$ctrl.phone.camera.primary}}
+ - Features
+ - {{$ctrl.phone.camera.features.join(', ')}}
+
+
+ -
+ Additional Features
+
- {{$ctrl.phone.additionalFeatures}}
+
+
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.component.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.component.spec.ts
new file mode 100644
index 0000000000..f0cf9987f9
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.component.spec.ts
@@ -0,0 +1,37 @@
+// #docregion top
+import './phone-list.module';
+// #enddocregion top
+
+describe('phoneList', function() {
+
+ // Load the module that contains the `phoneList` component before each test
+ beforeEach(angular.mock.module('phoneList'));
+
+ // Test the controller
+ describe('PhoneListController', function() {
+ var $httpBackend, ctrl;
+
+ beforeEach(inject(function($componentController, _$httpBackend_) {
+ $httpBackend = _$httpBackend_;
+ $httpBackend.expectGET('phones/phones.json')
+ .respond([{name: 'Nexus S'}, {name: 'Motorola DROID'}]);
+
+ ctrl = $componentController('phoneList', {$scope: {}});
+ }));
+
+ it('should create a `phones` model with 2 phones fetched with `$http`', function() {
+ jasmine.addCustomEqualityTester(angular.equals);
+
+ expect(ctrl.phones).toEqual([]);
+
+ $httpBackend.flush();
+ expect(ctrl.phones).toEqual([{name: 'Nexus S'}, {name: 'Motorola DROID'}]);
+ });
+
+ it('should set a default value for the `orderProp` model', function() {
+ expect(ctrl.orderProp).toBe('age');
+ });
+
+ });
+
+});
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.component.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.component.ts
new file mode 100644
index 0000000000..1d3f28e23a
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.component.ts
@@ -0,0 +1,18 @@
+// #docregion
+class PhoneListController {
+ phones:any[];
+ orderProp:string;
+ query:string;
+
+ static $inject = ['Phone'];
+ constructor(Phone) {
+ this.phones = Phone.query();
+ this.orderProp = 'age';
+ }
+
+}
+
+export default {
+ templateUrl: 'phone-list/phone-list.template.html',
+ controller: PhoneListController
+};
diff --git a/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.module.ts b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.module.ts
new file mode 100644
index 0000000000..feae92f9af
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.module.ts
@@ -0,0 +1,6 @@
+// #docregion
+import phoneList from './phone-list.component';
+import phone from '../core/phone/phone.module';
+
+export default angular.module('phoneList', [phone.name])
+ .component('phoneList', phoneList);
diff --git a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.html b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.template.html
similarity index 77%
rename from public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.html
rename to public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.template.html
index 471f474e89..95283ee032 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/typescript-conversion/app/js/phone_list/phone_list.html
+++ b/public/docs/_examples/upgrade-phonecat/ts/classes/app/phone-list/phone-list.template.html
@@ -3,9 +3,9 @@
- Search:
+ Search:
Sort by:
-
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-pipes.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-pipes.component.ts
new file mode 100644
index 0000000000..f7e568d9f0
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-pipes.component.ts
@@ -0,0 +1,21 @@
+// #docregion
+import {Component} from '@angular/core';
+import {Phone, PhoneData} from '../core/phone/phone.service';
+
+@Component({
+ selector: 'phone-list',
+ templateUrl: 'phone-list/phone-list.template.html'
+})
+export class PhoneList {
+ phones:PhoneData[];
+ orderProp:string;
+ query:string;
+
+ constructor(phone:Phone) {
+ phone.query().subscribe(phones => {
+ this.phones = phones;
+ });
+ this.orderProp = 'age';
+ }
+
+}
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list_without_pipes.html b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-pipes.template.html
similarity index 99%
rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list_without_pipes.html
rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-pipes.template.html
index 1a9d3fefb3..25618e578a 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list_without_pipes.html
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list-without-pipes.template.html
@@ -15,7 +15,6 @@
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phone_list.component.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.component.spec.ts
similarity index 79%
rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phone_list.component.spec.ts
rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.component.spec.ts
index d3d87f2a6f..4ef46ab338 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phone_list.component.spec.ts
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.component.spec.ts
@@ -2,6 +2,7 @@
import {provide} from '@angular/core';
import {HTTP_PROVIDERS} from '@angular/http';
import {Observable} from 'rxjs/Rx';
+
import {
describe,
beforeEachProviders,
@@ -11,13 +12,16 @@ import {
} from '@angular/core/testing';
import {TestComponentBuilder} from '@angular/compiler/testing';
-import PhoneList from '../../app/js/phone_list/phone_list.component';
-import {Phones, Phone} from '../../app/js/core/phones.service';
+import PhoneList from './phone-list.component';
+import {Phone, PhoneData} from '../core/phone/phone.service';
-class MockPhones extends Phones {
- query():Observable {
+class MockPhone extends Phone {
+ query():Observable {
return Observable.of(
- [{name: 'Nexus S', snippet: ''}, {name: 'Motorola DROID', snippet: ''}]
+ [
+ {name: 'Nexus S', snippet: '', images: []},
+ {name: 'Motorola DROID', snippet: '', images: []}
+ ]
)
}
}
@@ -25,25 +29,21 @@ class MockPhones extends Phones {
describe('PhoneList', () => {
beforeEachProviders(() => [
- provide(Phones, {useClass: MockPhones}),
+ provide(Phone, {useClass: MockPhone}),
HTTP_PROVIDERS
]);
-
it('should create "phones" model with 2 phones fetched from xhr',
inject([TestComponentBuilder], (tcb) => {
return tcb.createAsync(PhoneList).then((fixture) => {
fixture.detectChanges();
-
let compiled = fixture.debugElement.nativeElement;
-
expect(compiled.querySelectorAll('.phone-listing').length).toBe(2);
expect(compiled.querySelector('.phone-listing:nth-child(1)').textContent).toContain('Nexus S');
expect(compiled.querySelector('.phone-listing:nth-child(2)').textContent).toContain('Motorola DROID');
});
}));
-
it('should set the default value of orderProp model',
inject([TestComponentBuilder], (tcb) => {
return tcb.createAsync(PhoneList).then((fixture) => {
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.component.ts
new file mode 100644
index 0000000000..94b4491dba
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.component.ts
@@ -0,0 +1,25 @@
+// #docregion
+// #docregion top
+import {Component} from '@angular/core';
+import {Observable}Â from 'rxjs/Observable';
+import {Phone, PhoneData} from '../core/phone/phone.service';
+import PhoneFilterPipe from './phone-filter.pipe';
+import OrderByPipe from './order-by.pipe';
+
+@Component({
+ selector: 'phone-list',
+ templateUrl: 'phone-list/phone-list.template.html',
+ pipes: [PhoneFilterPipe, OrderByPipe]
+})
+// #enddocregion top
+export default class PhoneList {
+ phones:Observable;
+ orderProp:string;
+ query:string;
+
+ constructor(phone:Phone) {
+ this.phones = phone.query();
+ this.orderProp = 'age';
+ }
+
+}
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.module.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.module.ts
new file mode 100644
index 0000000000..6842d5a7fc
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.module.ts
@@ -0,0 +1,8 @@
+// #docregion
+import PhoneList from './phone-list.component';
+import phone from '../core/phone/phone.module';
+import upgradeAdapter from '../core/upgrade-adapter';
+
+export default angular.module('phoneList', [phone.name])
+ .directive('phoneList',
+ upgradeAdapter.downgradeNg2Component(PhoneList));
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list.html b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.template.html
similarity index 99%
rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list.html
rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.template.html
index 7934a38283..29dcf85365 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/js/phone_list/phone_list.html
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/phone-list/phone-list.template.html
@@ -15,7 +15,6 @@
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/systemjs.config.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/systemjs.config.js
index b7b216914c..5765cb282b 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/systemjs.config.js
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/app/systemjs.config.js
@@ -8,7 +8,7 @@ System.config({
'@angular': pkgPath + '@angular'
},
packages: {
- 'js': { defaultExtension: 'js' },
+ './': { defaultExtension: 'js' },
'@angular/common': { main: 'index.js', defaultExtension: 'js' },
'@angular/compiler': { main: 'index.js', defaultExtension: 'js' },
@@ -17,6 +17,7 @@ System.config({
'@angular/platform-browser': { main: 'index.js', defaultExtension: 'js' },
'@angular/platform-browser-dynamic': { main: 'index.js', defaultExtension: 'js' },
'@angular/router': { main: 'index.js', defaultExtension: 'js' },
+ '@angular/router-deprecated': { main: 'index.js', defaultExtension: 'js' },
'@angular/upgrade': { main: 'index.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' }
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/protractor-conf.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/e2e-tests/protractor-conf.js
similarity index 94%
rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/protractor-conf.js
rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/e2e-tests/protractor-conf.js
index 490e9bd078..6252ae848e 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/protractor-conf.js
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/e2e-tests/protractor-conf.js
@@ -2,7 +2,7 @@ exports.config = {
allScriptsTimeout: 11000,
specs: [
- 'e2e/*.js'
+ '*.js'
],
capabilities: {
@@ -10,7 +10,7 @@ exports.config = {
},
directConnect: true,
-
+
baseUrl: 'http://localhost:8000/',
framework: 'jasmine',
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/e2e/scenarios.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/e2e-tests/scenarios.js
similarity index 81%
rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/e2e/scenarios.js
rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/e2e-tests/scenarios.js
index 1da0896c0d..81f2d9f7fc 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/e2e/scenarios.js
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/e2e-tests/scenarios.js
@@ -18,6 +18,7 @@ describe('PhoneCat App', function() {
browser.get('app/index.html#/phones');
});
+
it('should filter the phone list as a user types into the search box', function() {
var phoneList = element.all(by.css('.phones li'));
var query = element(by.css('input'));
@@ -28,17 +29,13 @@ describe('PhoneCat App', function() {
expect(phoneList.count()).toBe(1);
query.clear();
- // https://github.com/angular/protractor/issues/2019
- var str = 'motorola';
- for (var i = 0; i < str.length; i++) {
- query.sendKeys(str.charAt(i));
- }
-
+ query.sendKeys('motorola');
expect(phoneList.count()).toBe(8);
});
it('should be possible to control phone order via the drop down select box', function() {
+
var phoneNameColumn = element.all(by.css('.phones .name'));
var query = element(by.css('input'));
@@ -48,12 +45,7 @@ describe('PhoneCat App', function() {
});
}
- //let's narrow the dataset to make the test assertions shorter
- // https://github.com/angular/protractor/issues/2019
- var str = 'tablet';
- for (var i = 0; i < str.length; i++) {
- query.sendKeys(str.charAt(i));
- }
+ query.sendKeys('tablet'); //let's narrow the dataset to make the test assertions shorter
expect(getNames()).toEqual([
"Motorola XOOM\u2122 with Wi-Fi",
@@ -71,11 +63,7 @@ describe('PhoneCat App', function() {
it('should render phone specific links', function() {
var query = element(by.css('input'));
- // https://github.com/angular/protractor/issues/2019
- var str = 'nexus';
- for (var i = 0; i < str.length; i++) {
- query.sendKeys(str.charAt(i));
- }
+ query.sendKeys('nexus');
element.all(by.css('.phones li a')).first().click();
browser.getLocationAbsUrl().then(function(url) {
expect(url).toEqual('/phones/nexus-s');
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/karma.conf.1.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/karma.conf.1.js
new file mode 100644
index 0000000000..2c6ae448a0
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/karma.conf.1.js
@@ -0,0 +1,59 @@
+module.exports = function(config){
+ config.set({
+
+ baseDir: '.',
+
+ // #docregion ng2
+ // #docregion html
+ files : [
+ // #enddocregion html
+ // #enddocregion ng2
+ 'app/bower_components/angular/angular.js',
+ 'app/bower_components/angular-route/angular-route.js',
+ 'app/bower_components/angular-resource/angular-resource.js',
+ 'app/bower_components/angular-animate/angular-animate.js',
+ 'app/bower_components/angular-mocks/angular-mocks.js',
+ 'node_modules/systemjs/dist/system-polyfills.js',
+ 'node_modules/systemjs/dist/system.src.js',
+ // #docregion ng2
+ 'node_modules/es6-shim/es6-shim.js',
+ 'node_modules/zone.js/dist/zone.js',
+ 'node_modules/reflect-metadata/Reflect.js',
+ {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false},
+ {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
+ // #enddocregion ng2
+ 'karma_test_shim.js',
+ {pattern: 'app/**/*.module.js', included: false, watched: true},
+ {pattern: 'app/*!(.module|.spec).js', included: false, watched: true},
+ {pattern: 'app/!(bower_components)/**/*!(.module|.spec).js', included: false, watched: true},
+ {pattern: 'app/**/*.spec.js', included: false, watched: true},
+ // #docregion html
+ {pattern: 'app/**/*.html', included: false, watched: true}
+ // #docregion ng2
+ ],
+ // #enddocregion ng2
+
+ proxies: {
+ // required for component assets fetched by Angular's compiler
+ "/": "/base/app/"
+ },
+ // #enddocregion html
+
+ autoWatch : true,
+
+ frameworks: ['jasmine'],
+
+ browsers : ['Chrome', 'Firefox'],
+
+ plugins : [
+ 'karma-chrome-launcher',
+ 'karma-firefox-launcher',
+ 'karma-jasmine'
+ ],
+
+ junitReporter : {
+ outputFile: 'test_out/unit.xml',
+ suite: 'unit'
+ }
+ });
+};
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/karma_test_shim.js b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/karma_test_shim.js
similarity index 75%
rename from public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/karma_test_shim.js
rename to public/docs/_examples/upgrade-phonecat/ts/ng2_components/karma_test_shim.js
index 7aa6c9ec90..edb4033652 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/karma_test_shim.js
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/karma_test_shim.js
@@ -5,11 +5,11 @@ __karma__.loaded = function() {};
System.config({
map: {
- 'rxjs': 'base/node_modules/rxjs',
- '@angular': 'base/node_modules/@angular'
+ 'rxjs': 'base/node_modules/rxjs',
+ '@angular': 'base/node_modules/@angular'
},
packages: {
- 'base/app/js': {
+ 'base': {
defaultExtension: false,
format: 'register',
map: Object.keys(window.__karma__.files).
@@ -17,7 +17,7 @@ System.config({
reduce(function createPathRecords(pathsMapping, appPath) {
// creates local module name mapping to global path with karma's fingerprint in path, e.g.:
// './hero.service': '/base/src/app/hero.service.js?f4523daf879cfb7310ef6242682ccf10b2041b3e'
- var moduleName = appPath.replace(/^\/base\/app\/js\//, './').replace(/\.js$/, '');
+ var moduleName = appPath.replace(/^\/base\//, './').replace(/\.js$/, '');
pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath]
return pathsMapping;
}, {})
@@ -29,6 +29,7 @@ System.config({
'@angular/platform-browser': { main: 'index.js', defaultExtension: 'js' },
'@angular/platform-browser-dynamic': { main: 'index.js', defaultExtension: 'js' },
'@angular/router': { main: 'index.js', defaultExtension: 'js' },
+ '@angular/router-deprecated': { main: 'index.js', defaultExtension: 'js' },
'@angular/upgrade': { main: 'index.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' }
}
@@ -37,26 +38,26 @@ System.config({
// #docregion ng2
System.import('@angular/core/testing').then(function(testing) {
return System.import('@angular/platform-browser-dynamic/testing').then(function(browserTesting) {
- testing.setBaseTestProviders(browserTesting.TEST_BROWSER_PLATFORM_PROVIDERS,
- browserTesting.TEST_BROWSER_APPLICATION_PROVIDERS);
+ testing.setBaseTestProviders(browserTesting.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
+ browserTesting.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
});
}).then(function() {
- return Promise.all(
+ Promise.all(
Object.keys(window.__karma__.files) // All files served by Karma.
.filter(onlySpecFiles)
.map(function(moduleName) {
// loads all spec files via their global module names
return System.import(moduleName);
- }));
-}).then(function() {
- __karma__.start();
-}, function(error) {
- __karma__.error(error.stack || error);
+ }))
+ .then(function() {
+ __karma__.start();
+ }, function(error) {
+ __karma__.error(error.stack || error);
+ });
});
-// #enddocregion ng2
function onlyAppFiles(filePath) {
- return /^\/base\/app\/js\/.*\.js$/.test(filePath)
+ return /^\/base\/.*\.(?!\.spec\.)js$/.test(filePath)
}
function onlySpecFiles(path) {
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/package.1.json b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/package.1.json
index 425ad7b82f..15902577d7 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/package.1.json
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/package.1.json
@@ -6,14 +6,15 @@
"repository": "https://github.com/angular/angular-phonecat",
"license": "MIT",
"dependencies": {
- "@angular/common": "0.0.0-3",
- "@angular/compiler": "0.0.0-3",
- "@angular/core": "0.0.0-3",
- "@angular/http": "0.0.0-3",
- "@angular/platform-browser": "0.0.0-3",
- "@angular/platform-browser-dynamic": "0.0.0-3",
- "@angular/router": "0.0.0-3",
- "@angular/upgrade": "0.0.0-3",
+ "@angular/common": "2.0.0-rc.1",
+ "@angular/compiler": "2.0.0-rc.1",
+ "@angular/core": "2.0.0-rc.1",
+ "@angular/http": "2.0.0-rc.1",
+ "@angular/platform-browser": "2.0.0-rc.1",
+ "@angular/platform-browser-dynamic": "2.0.0-rc.1",
+ "@angular/router": "2.0.0-rc.1",
+ "@angular/router-deprecated": "2.0.0-rc.1",
+ "@angular/upgrade": "2.0.0-rc.1",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.3",
@@ -27,28 +28,22 @@
"karma-firefox-launcher": "^0.1.3",
"karma-jasmine": "~0.3.7",
"protractor": "^3.0.0",
- "http-server": "^0.6.1",
- "tmp": "0.0.23",
- "bower": "^1.3.1",
"shelljs": "^0.2.6",
"typescript": "1.8.10",
"typings": "^0.7.12"
},
"scripts": {
"postinstall": "bower install",
-
"prestart": "npm install",
"start": "http-server -a 0.0.0.0 -p 8000",
- "test": "node node_modules/karma/bin/karma start test/karma.conf.js",
- "test-single-run": "node node_modules/karma/bin/karma start test/karma.conf.js --single-run",
+ "test": "node node_modules/karma/bin/karma start karma.conf.js",
+ "test-single-run": "node node_modules/karma/bin/karma start karma.conf.js --single-run",
"preupdate-webdriver": "npm install",
"update-webdriver": "webdriver-manager update",
-
"preprotractor": "npm run update-webdriver",
- "protractor": "protractor test/protractor-conf.js",
-
+ "protractor": "protractor e2e-tests/protractor-conf.js",
"typings": "typings",
"tsc": "tsc -p . -w"
}
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phones.service.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phones.service.spec.ts
deleted file mode 100644
index c70f25c5ca..0000000000
--- a/public/docs/_examples/upgrade-phonecat/ts/ng2_components/test/unit/phones.service.spec.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-// #docregion
-import {describe, beforeEachProviders, it, inject} from '@angular/core/testing';
-import {HTTP_PROVIDERS} from '@angular/http';
-import {Phones} from '../../app/js/core/phones.service';
-
-describe('Phones', function() {
-
- // load providers
- beforeEachProviders(() => [Phones, HTTP_PROVIDERS]);
-
- // Test service availability
- it('check the existence of Phones', inject([Phones], (phones) => {
- expect(phones).toBeDefined();
- }));
-
-});
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/app.component.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/app.component.ts
similarity index 62%
rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/app.component.ts
rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/app.component.ts
index a959a641a2..bfcc6e391a 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/app.component.ts
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/app.component.ts
@@ -1,9 +1,9 @@
// #docregion
import { Component } from '@angular/core';
-import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router';
+import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated';
-import PhoneList from './phone_list/phone_list.component';
-import PhoneDetail from './phone_detail/phone_detail.component';
+import PhoneList from './phone-list/phone-list.component';
+import PhoneDetail from './phone-detail/phone-detail.component';
@RouteConfig([
{path:'/phones', name: 'Phones', component: PhoneList},
@@ -11,7 +11,7 @@ import PhoneDetail from './phone_detail/phone_detail.component';
{path:'/', redirectTo: ['Phones']}
])
@Component({
- selector: 'pc-app',
+ selector: 'phonecat-app',
template: '',
directives: [ROUTER_DIRECTIVES]
})
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/checkmark.pipe.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/checkmark/checkmark.pipe.spec.ts
similarity index 80%
rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/checkmark.pipe.spec.ts
rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/checkmark/checkmark.pipe.spec.ts
index c9a1def071..aedfbd011b 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/test/unit/checkmark.pipe.spec.ts
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/checkmark/checkmark.pipe.spec.ts
@@ -1,9 +1,9 @@
// #docregion
import { describe, beforeEachProviders, it, inject, expect } from '@angular/core/testing';
-import { CheckmarkPipe } from '../../app/js/core/checkmark.pipe';
+import {CheckmarkPipe} from './checkmark.pipe';
-describe('CheckmarkPipe', () => {
+describe('CheckmarkPipe', function() {
beforeEachProviders(() => [CheckmarkPipe]);
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/core/checkmark.pipe.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/checkmark/checkmark.pipe.ts
similarity index 53%
rename from public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/core/checkmark.pipe.ts
rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/checkmark/checkmark.pipe.ts
index d129a44e50..68a40c8b00 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/js/core/checkmark.pipe.ts
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/checkmark/checkmark.pipe.ts
@@ -1,8 +1,8 @@
// #docregion
-import { Pipe } from '@angular/core';
+import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'checkmark'})
-export class CheckmarkPipe {
+export class CheckmarkPipe implements PipeTransform {
transform(input:string): string {
return input ? '\u2713' : '\u2718';
}
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/phone/phone.service.spec.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/phone/phone.service.spec.ts
new file mode 100644
index 0000000000..e0dceedfa3
--- /dev/null
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/phone/phone.service.spec.ts
@@ -0,0 +1,43 @@
+// #docregion
+import {provide} from '@angular/core';
+import {describe, beforeEach, beforeEachProviders, it, inject} from '@angular/core/testing';
+import {Http, BaseRequestOptions, ResponseOptions, Response} from '@angular/http';
+import {MockBackend} from '@angular/http/testing';
+import {Phone, PhoneData} from './phone.service';
+
+describe('Phone', function() {
+ var phone;
+ var phonesData:PhoneData[] = [
+ {name: 'Phone X', snippet: '', images: []},
+ {name: 'Phone Y', snippet: '', images: []},
+ {name: 'Phone Z', snippet: '', images: []}
+ ];
+ var mockBackend;
+
+ // load providers
+ beforeEachProviders(() => [
+ Phone,
+ MockBackend,
+ BaseRequestOptions,
+ provide(Http, {
+ useFactory: (backend, options) => new Http(backend, options),
+ deps: [MockBackend, BaseRequestOptions]
+ })
+ ]);
+
+ beforeEach(inject([MockBackend, Phone], (_mockBackend_, _phone_) => {
+ mockBackend = _mockBackend_;
+ phone = _phone_;
+ }));
+
+ it('should fetch the phones data from `/phones/phones.json`', (done) => {
+ mockBackend.connections.subscribe(connection => {
+ connection.mockRespond(new Response(new ResponseOptions({body: JSON.stringify(phonesData)})));
+ });
+ phone.query().subscribe(result => {
+ expect(result).toEqual(phonesData);
+ done();
+ });
+ });
+
+});
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/phones.service.ts b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/phone/phone.service.ts
similarity index 75%
rename from public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/phones.service.ts
rename to public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/phone/phone.service.ts
index 96cce48520..aabc995b3c 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/ng2_initial/app/js/core/phones.service.ts
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/core/phone/phone.service.ts
@@ -5,34 +5,32 @@ import { Observable } from 'rxjs/Rx';
import 'rxjs/add/operator/map';
-// #docregion phone-interface
-export interface Phone {
+// #docregion phonedata-interface
+export interface PhoneData {
name: string;
snippet: string;
images: string[];
}
-// #enddocregion phone-interface
+// #enddocregion phonedata-interface
-// #docregion fullclass
// #docregion class
+// #docregion fullclass
@Injectable()
-export class Phones {
+export class Phone {
// #enddocregion class
constructor(private http: Http) { }
- query():Observable {
+ query():Observable {
return this.http.get(`phones/phones.json`)
.map((res:Response) => res.json());
}
- get(id: string):Observable {
+ get(id: string):Observable {
return this.http.get(`phones/${id}.json`)
.map((res:Response) => res.json());
}
-
// #docregion class
}
-// #enddocregion class
// #enddocregion fullclass
-// #docregion full
+// #enddocregion class
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/css/.gitkeep b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/css/.gitkeep
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/index.html b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/index.html
index a1dfd126cf..d255279e0c 100644
--- a/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/index.html
+++ b/public/docs/_examples/upgrade-phonecat/ts/ng2_final/app/index.html
@@ -14,13 +14,13 @@
-
+