Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 11b8e2e

Browse files
committed
docs(ugprade): bring phonecat upgrade tutorial up to speed with modernized Angular 1.x PhoneCat
Relates to angular/angular-phonecat#326
1 parent f1c1069 commit 11b8e2e

File tree

185 files changed

+2105
-1927
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+2105
-1927
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// #docregion
2+
export default ['$routeProvider',
3+
function config($routeProvider) {
4+
$routeProvider.
5+
when('/phones', {
6+
template: '<phone-list></phone-list>'
7+
}).
8+
when('/phones/:phoneId', {
9+
template: '<phone-detail></phone-detail>'
10+
}).
11+
otherwise('/phones');
12+
}];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// #docregion pre-bootstrap
2+
import core from './core/core.module';
3+
import phoneList from './phone-list/phone-list.module';
4+
import phoneDetail from './phone-detail/phone-detail.module';
5+
import appConfig from './app.config';
6+
7+
angular.module('phonecatApp', [
8+
'ngAnimate',
9+
'ngRoute',
10+
core.name,
11+
phoneList.name,
12+
phoneDetail.name
13+
]).config(appConfig);
14+
15+
// #enddocregion pre-bootstrap
16+
// #docregion bootstrap
17+
angular.bootstrap(document.documentElement, ['phonecatApp']);
18+
// #enddocregion bootstrap

public/docs/_examples/upgrade-phonecat/ts/classes/test/unit/checkmark.filter.spec.ts renamed to public/docs/_examples/upgrade-phonecat/ts/classes/app/core/checkmark/checkmark.filter.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// #docregion top
2-
import '../../app/js/core/core.module';
2+
import '../core.module';
33
// #enddocregion top
44

55
describe('checkmarkFilter', function() {
66

7-
beforeEach(angular.mock.module('phonecat.core'));
7+
beforeEach(angular.mock.module('core'));
88

99
it('should convert boolean values to unicode checkmark or cross',
1010
inject(function(checkmarkFilter) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// #docregion
2+
import checkmarkFilter from './checkmark/checkmark.filter';
3+
import phone from './phone/phone.module';
4+
5+
export default angular.module('core', [phone.name])
6+
.filter('checkmark', checkmarkFilter);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// #docregion
2+
import Phone from './phone.service';
3+
4+
export default angular.module('core.phone', ['ngResource'])
5+
.factory('Phone', Phone);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// #docregion top
2+
import './phone.module';
3+
// #enddocregion top
4+
5+
'use strict';
6+
7+
describe('Phone', function() {
8+
var $httpBackend;
9+
var Phone;
10+
var phonesData = [
11+
{name: 'Phone X'},
12+
{name: 'Phone Y'},
13+
{name: 'Phone Z'}
14+
];
15+
16+
// Add a custom equality tester before each test
17+
beforeEach(function() {
18+
jasmine.addCustomEqualityTester(angular.equals);
19+
});
20+
21+
// Load the module that contains the `Phone` service before each test
22+
beforeEach(angular.mock.module('core.phone'));
23+
24+
// Instantiate the service and "train" `$httpBackend` before each test
25+
beforeEach(inject(function(_$httpBackend_, _Phone_) {
26+
$httpBackend = _$httpBackend_;
27+
$httpBackend.expectGET('phones/phones.json').respond(phonesData);
28+
29+
Phone = _Phone_;
30+
}));
31+
32+
// Verify that there are no outstanding expectations or requests after each test
33+
afterEach(function () {
34+
$httpBackend.verifyNoOutstandingExpectation();
35+
$httpBackend.verifyNoOutstandingRequest();
36+
});
37+
38+
it('should fetch the phones data from `/phones/phones.json`', function() {
39+
var phones = Phone.query();
40+
41+
expect(phones).toEqual([]);
42+
43+
$httpBackend.flush();
44+
expect(phones).toEqual(phonesData);
45+
});
46+
47+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// #docregion
2+
export default ['$resource',
3+
function Phone($resource) {
4+
return $resource('phones/:phoneId.json', {}, {
5+
query: {
6+
method: 'GET',
7+
params: {phoneId: 'phones'},
8+
isArray: true
9+
}
10+
});
11+
}
12+
];

public/docs/_examples/upgrade-phonecat/ts/classes/app/css/.gitkeep

Whitespace-only changes.

public/docs/_examples/upgrade-phonecat/ts/classes/app/index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<meta charset="utf-8">
55
<title>Google Phone Gallery</title>
66
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
7-
<link rel="stylesheet" href="css/app.css">
8-
<link rel="stylesheet" href="css/animations.css">
7+
<link rel="stylesheet" href="app.css">
8+
<link rel="stylesheet" href="app.animations.css">
99
<!-- #docregion scripts -->
1010
<script src="../node_modules/systemjs/dist/system.src.js"></script>
1111
<script src="bower_components/jquery/dist/jquery.js"></script>
@@ -15,7 +15,7 @@
1515
<script src="bower_components/angular-resource/angular-resource.js"></script>
1616
<script src="systemjs.config.js"></script>
1717
<script>
18-
System.import('js/app.module');
18+
System.import('./app.module');
1919
</script>
2020
<!-- #enddocregion scripts -->
2121
</head>

public/docs/_examples/upgrade-phonecat/ts/classes/app/js/app.module.ts

-35
This file was deleted.

public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/core.module.ts

-9
This file was deleted.

public/docs/_examples/upgrade-phonecat/ts/classes/app/js/core/phone.factory.ts

-10
This file was deleted.

public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.controller.ts

-22
This file was deleted.

public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.html

-118
This file was deleted.

public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_detail/phone_detail.module.ts

-8
This file was deleted.

public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.controller.ts

-14
This file was deleted.

public/docs/_examples/upgrade-phonecat/ts/classes/app/js/phone_list/phone_list.module.ts

-5
This file was deleted.

0 commit comments

Comments
 (0)