diff --git a/README.md b/README.md
index d93a6f8..fdf17f3 100644
--- a/README.md
+++ b/README.md
@@ -18,4 +18,14 @@ To run the application we type
`npm start` - this loads the application using a local webserver, check the console for the port number to use.
-The application is a simple contacts application where you can search, create or edit a contact.
\ No newline at end of file
+The application is a simple contacts application where you can search, create or edit a contact.
+
+# Steps for Migration.
+
+Preparing for migration:
+
+STEP 1:
+
+Follow the step 1 of angular style guide https://github.com/johnpapa/angular-styleguide
+
+Single Responsibility: Organize the code in such a maner that 1 file contains only one component.
\ No newline at end of file
diff --git a/src/app/controllers.js b/src/app/controllers.js
deleted file mode 100644
index f78828c..0000000
--- a/src/app/controllers.js
+++ /dev/null
@@ -1,48 +0,0 @@
-angular
- .module("codecraft")
- .controller("PersonCreateController", function(
- $scope,
- $state,
- ContactService
- ) {
- $scope.contacts = ContactService;
- $scope.person = {};
-
- $scope.save = function() {
- console.log("createContact");
- $scope.contacts.createContact($scope.person).then(function() {
- $state.go("list");
- });
- };
- })
- .controller("PersonEditController", function(
- $scope,
- $stateParams,
- $state,
- ContactService
- ) {
- $scope.contacts = ContactService;
- $scope.person = $scope.contacts.getPerson($stateParams.email);
-
- $scope.save = function() {
- $scope.contacts.updateContact($scope.person).then(function() {
- $state.go("list");
- });
- };
-
- $scope.remove = function() {
- $scope.contacts.removeContact($scope.person).then(function() {
- $state.go("list");
- });
- };
- })
- .controller("PersonListController", function($scope, ContactService) {
- $scope.contacts = ContactService;
- })
- .controller("SearchController", function($scope, ContactService) {
- $scope.contacts = ContactService;
-
- $scope.loadMore = function() {
- $scope.contacts.loadMore();
- };
- });
diff --git a/src/app/controllers/person-create.controller.js b/src/app/controllers/person-create.controller.js
new file mode 100644
index 0000000..0b90189
--- /dev/null
+++ b/src/app/controllers/person-create.controller.js
@@ -0,0 +1,17 @@
+angular
+ .module("codecraft")
+ .controller("PersonCreateController", function(
+ $scope,
+ $state,
+ ContactService
+ ) {
+ $scope.contacts = ContactService;
+ $scope.person = {};
+
+ $scope.save = function() {
+ console.log("createContact");
+ $scope.contacts.createContact($scope.person).then(function() {
+ $state.go("list");
+ });
+ };
+ })
diff --git a/src/app/controllers/person-edit.controller.js b/src/app/controllers/person-edit.controller.js
new file mode 100644
index 0000000..f6d76f7
--- /dev/null
+++ b/src/app/controllers/person-edit.controller.js
@@ -0,0 +1,23 @@
+angular
+ .module("codecraft")
+ .controller("PersonEditController", function(
+ $scope,
+ $stateParams,
+ $state,
+ ContactService
+ ) {
+ $scope.contacts = ContactService;
+ $scope.person = $scope.contacts.getPerson($stateParams.email);
+
+ $scope.save = function() {
+ $scope.contacts.updateContact($scope.person).then(function() {
+ $state.go("list");
+ });
+ };
+
+ $scope.remove = function() {
+ $scope.contacts.removeContact($scope.person).then(function() {
+ $state.go("list");
+ });
+ };
+ })
\ No newline at end of file
diff --git a/src/app/controllers/person-list.controller.js b/src/app/controllers/person-list.controller.js
new file mode 100644
index 0000000..258191e
--- /dev/null
+++ b/src/app/controllers/person-list.controller.js
@@ -0,0 +1,5 @@
+angular
+ .module("codecraft")
+ .controller("PersonListController", function($scope, ContactService) {
+ $scope.contacts = ContactService;
+ })
diff --git a/src/app/controllers/search.controller.js b/src/app/controllers/search.controller.js
new file mode 100644
index 0000000..5c70fed
--- /dev/null
+++ b/src/app/controllers/search.controller.js
@@ -0,0 +1,9 @@
+angular
+ .module("codecraft")
+ .controller("SearchController", function($scope, ContactService) {
+ $scope.contacts = ContactService;
+
+ $scope.loadMore = function() {
+ $scope.contacts.loadMore();
+ };
+ });
diff --git a/src/app/directives.js b/src/app/directives/card.directive.js
similarity index 71%
rename from src/app/directives.js
rename to src/app/directives/card.directive.js
index 5a6d920..b7ccd3a 100644
--- a/src/app/directives.js
+++ b/src/app/directives/card.directive.js
@@ -18,13 +18,3 @@ angular
}
};
})
- .directive("ccSpinner", function() {
- return {
- restrict: "AE",
- templateUrl: "templates/spinner.html",
- scope: {
- isLoading: "=",
- message: "@"
- }
- };
- });
diff --git a/src/app/directives/spinner.directive.js b/src/app/directives/spinner.directive.js
new file mode 100644
index 0000000..0d452cc
--- /dev/null
+++ b/src/app/directives/spinner.directive.js
@@ -0,0 +1,12 @@
+angular
+ .module("codecraft")
+ .directive("ccSpinner", function() {
+ return {
+ restrict: "AE",
+ templateUrl: "templates/spinner.html",
+ scope: {
+ isLoading: "=",
+ message: "@"
+ }
+ };
+ });
diff --git a/src/app/filters.js b/src/app/filters.js
deleted file mode 100644
index 13193f3..0000000
--- a/src/app/filters.js
+++ /dev/null
@@ -1,11 +0,0 @@
-angular.module("codecraft").filter("defaultImage", function() {
- return function(input, param) {
- if (!param) {
- param = "/img/avatar.png";
- }
- if (!input) {
- return param;
- }
- return input;
- };
-});
diff --git a/src/app/filters/default-image.filter.js b/src/app/filters/default-image.filter.js
new file mode 100644
index 0000000..3f38243
--- /dev/null
+++ b/src/app/filters/default-image.filter.js
@@ -0,0 +1,12 @@
+angular.module("codecraft").filter("defaultImage", function() {
+ return function(input, param) {
+ if (!param) {
+ param = "/img/avatar.png";
+ }
+ if (!input) {
+ return param;
+ }
+ return input;
+ };
+ });
+
\ No newline at end of file
diff --git a/src/app/services/contact.resource.js b/src/app/services/contact.resource.js
new file mode 100644
index 0000000..59bb68f
--- /dev/null
+++ b/src/app/services/contact.resource.js
@@ -0,0 +1,13 @@
+angular
+ .module("codecraft")
+ .factory("Contact", function($resource) {
+ return $resource(
+ "http://localhost:3000/contacts/:id",
+ {id: "@id"},
+ {
+ update: {
+ method: "PUT"
+ }
+ }
+ );
+ })
diff --git a/src/app/services.js b/src/app/services/contact.service.js
similarity index 93%
rename from src/app/services.js
rename to src/app/services/contact.service.js
index dc5196b..7f747cd 100644
--- a/src/app/services.js
+++ b/src/app/services/contact.service.js
@@ -1,16 +1,5 @@
angular
.module("codecraft")
- .factory("Contact", function($resource) {
- return $resource(
- "http://localhost:3000/contacts/:id",
- {id: "@id"},
- {
- update: {
- method: "PUT"
- }
- }
- );
- })
.factory("ContactService", function(Contact, $rootScope, $q, toaster) {
var self = {
getPerson: function(email) {
diff --git a/src/index.html b/src/index.html
index 25ff5e7..bd9d833 100644
--- a/src/index.html
+++ b/src/index.html
@@ -65,13 +65,17 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+