diff --git a/README.md b/README.md
index 27c4042..072991a 100644
--- a/README.md
+++ b/README.md
@@ -96,5 +96,19 @@ The application is a simple contacts application where you can search, create or
- It depends on a 3rd party component called Toaster which only works in AngularJS, so we upgrade Toaster to use it in Angular via `ajs-upgraded-providers.ts`
- We inject our upgraded Toaster using the `@Inject` annotation.
-
+### Step 8 - Components to Angular
+*Components*
+- Convert all the components to Angular components, during this process we will need to deal with a bunch of 3rd party modules.
+ - For the 3rd party AngularJS `angular-ladda` module we use the Angular version `angular2-ladda`
+ - For the 3rd party AngularJS `ng-infinite-scroll` module we use the Angular version `angular2-infinite-scroll`
+ - For the `angular-spinner` 3rd party AngularJS module we re-write from scratch in Angular using the underlying `spin.js` library.
+ - Since filters can't be upgraded we just need to re-write our `defaultImage` filter as a pipe
+ - We also update the template HTML to use Angular syntax instead of AngularJS syntax.
+ - We then add out components to `NgModule`, ensuring we add as both declarations and entry components so we can use them in AngularJS templates.
+
+
+*UI-Router*
+- Our component code uses ui-router, we will eventually move to using Angular router so for now we just need a patch to continue letting us use ui-router in this hybrid mode.
+ - We upgrade the ui-router services so we can use them in Angular, see `ajs-upgraded-providers.ts`
+ - We stop using ui-router directive such as `ui-sref` and instead hard code URLS in the template.
diff --git a/package.json b/package.json
index e16a6f9..26bae30 100644
--- a/package.json
+++ b/package.json
@@ -39,16 +39,21 @@
"jquery": "2.1.3",
"ng-infinite-scroll": "1.2.1",
"angular-ui-router": "^0.4.2",
- "angular-spinner": "^1.0.1"
+ "angular-spinner": "^1.0.1",
+ "angular2-infinite-scroll": "^0.3.3",
+ "angular2-ladda": "^1.1.1",
+ "spin.js": "^2.3.2"
},
"devDependencies": {
- "@types/angular": "^1.4.0",
+ "@types/angular": "^1.6.2",
+ "@types/spin.js": "^2.3.0",
"bower": "^1.8.0",
"json-server": "^0.9.6",
"serve": "^5.1.2",
"rimraf": "^2.6.0",
"ts-loader": "^2.0.1",
"typescript": "^2.2.1",
- "webpack": "^2.2.1"
+ "webpack": "^2.2.1",
+ "script-loader": "^0.7.0"
}
}
diff --git a/src/app/ajs-upgraded-providers.ts b/src/app/ajs-upgraded-providers.ts
index 0fe1c16..9069249 100644
--- a/src/app/ajs-upgraded-providers.ts
+++ b/src/app/ajs-upgraded-providers.ts
@@ -8,4 +8,27 @@ export const toasterServiceProvider = {
provide: Toaster,
useFactory: toasterServiceFactory,
deps: ['$injector']
+};
+
+export const UIRouterState = new OpaqueToken("UIRouterState");
+
+export function uiRouterStateServiceFactory(i: any) {
+ return i.get('$state');
+}
+export const uiRouterStateProvider = {
+ provide: UIRouterState,
+ useFactory: uiRouterStateServiceFactory,
+ deps: ['$injector']
+};
+
+
+export const UIRouterStateParams = new OpaqueToken("UIRouterStateParams");
+
+export function uiRouterStateParamsServiceFactory(i: any) {
+ return i.get('$stateParams');
+}
+export const uiRouterStateParamsProvider = {
+ provide: UIRouterStateParams,
+ useFactory: uiRouterStateParamsServiceFactory,
+ deps: ['$injector']
};
\ No newline at end of file
diff --git a/src/app/components/card.component.ts b/src/app/components/card.component.ts
index 09a027b..7a836b7 100644
--- a/src/app/components/card.component.ts
+++ b/src/app/components/card.component.ts
@@ -1,71 +1,63 @@
-import * as angular from 'angular';
+import {Input, Component} from "@angular/core";
+import {ContactService} from "../services/contact.service";
-let CardComponent = {
+@Component({
selector: 'ccCard',
template: `
No results found for search term '{{ contacts.search }}'
+
+
+
+
+
+`
+})
+export class PersonListComponent {
+ constructor(public contacts: ContactService) {
+ }
+
+ loadMore() {
+ console.log("loadMore");
+ this.contacts.loadMore();
}
-};
+}
+
angular
.module('codecraft')
- .component(PersonListComponent.selector, PersonListComponent);
\ No newline at end of file
+ .directive('personList', downgradeComponent({
+ component: PersonListComponent
+ }) as angular.IDirectiveFactory);
\ No newline at end of file
diff --git a/src/app/components/person-modify.component.html b/src/app/components/person-modify.component.html
new file mode 100644
index 0000000..21c0c0a
--- /dev/null
+++ b/src/app/components/person-modify.component.html
@@ -0,0 +1,134 @@
+
+
+
\ No newline at end of file
diff --git a/src/app/components/search.component.ts b/src/app/components/search.component.ts
index 0ddc1e2..8e4ea63 100644
--- a/src/app/components/search.component.ts
+++ b/src/app/components/search.component.ts
@@ -1,26 +1,28 @@
import * as angular from 'angular';
+import {Component} from "@angular/core";
+import {downgradeComponent} from "@angular/upgrade/static";
+import {ContactService} from "../services/contact.service";
+import {
+ FormGroup,
+ FormControl
+} from '@angular/forms';
-export let SearchComponent = {
+@Component({
selector: 'search',
template: `
-