├── Finished-Items.page-controller.js ├── README.md ├── Todo-Item.page-controller.js ├── Todos.page-controller.js └── todos.js /Finished-Items.page-controller.js: -------------------------------------------------------------------------------- 1 | // The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller 2 | // You can include any angular dependencies as parameters for this function 3 | // TIP: Access Route Parameters for your page via $stateParams.parameterName 4 | function ($scope, $stateParams, Todos) { 5 | 6 | $scope.items = Todos.items; 7 | 8 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Creator Custom Code Support Deep Dive Code 2 | If you want to follow along with our [deep dive video](https://www.youtube.com/watch?v=IrwrZBBOiP8) you can copy and paste this final code into your own Creator project. Be sure to replace your own Firebase data in todos.js. 3 | 4 | You will still have to follow along with the demo to add Directives and components, as well as add the Dependencies required, but this will contain all of the JavaScript code you need. 5 | -------------------------------------------------------------------------------- /Todo-Item.page-controller.js: -------------------------------------------------------------------------------- 1 | // The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller 2 | // You can include any angular dependencies as parameters for this function 3 | // TIP: Access Route Parameters for your page via $stateParams.parameterName 4 | function ($scope, $stateParams, Todos) { 5 | 6 | // $scope.itemid = $stateParams.item; 7 | 8 | $scope.item = Todos.items[Todos.items.$indexFor($stateParams.item)]; 9 | 10 | $scope.toggleFinished = function(){ 11 | if ($scope.item.finished){ 12 | Todos.setFinished($scope.item, false); 13 | }else{ 14 | Todos.setFinished($scope.item, true); 15 | } 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /Todos.page-controller.js: -------------------------------------------------------------------------------- 1 | // The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller 2 | // You can include any angular dependencies as parameters for this function 3 | // TIP: Access Route Parameters for your page via $stateParams.parameterName 4 | function ($scope, $stateParams, Todos, $ionicModal) { 5 | 6 | $scope.items = Todos.items; 7 | 8 | $scope.data = { 9 | 'title': '' 10 | } 11 | 12 | $scope.modal = $ionicModal.fromTemplate("" + 13 | "" + 14 | "

Add a Todo

" + 15 | '' + 16 | "
" + 17 | "" + 18 | "" + 19 | "" + 20 | "" + 21 | "
", { 22 | scope: $scope, 23 | animation: 'slide-in-up' 24 | }) 25 | 26 | $scope.showModal = function(){ 27 | $scope.modal.show(); 28 | } 29 | 30 | $scope.closeModal = function(){ 31 | $scope.data.title = ''; 32 | $scope.modal.hide(); 33 | } 34 | 35 | $scope.addItem = function(){ 36 | Todos.addItem($scope.data.title); 37 | $scope.closeModal(); 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /todos.js: -------------------------------------------------------------------------------- 1 | angular.module('todos', ['firebase']) 2 | 3 | .run(function(){ 4 | 5 | // Initialize Firebase 6 | var config = { 7 | apiKey: "", 8 | authDomain: "", 9 | databaseURL: "", 10 | storageBucket: "", 11 | }; 12 | firebase.initializeApp(config); 13 | 14 | }) 15 | 16 | .service('Todos', ['$firebaseArray', function($firebaseArray){ 17 | 18 | var ref = firebase.database().ref().child('todos'); 19 | var items = $firebaseArray(ref); 20 | 21 | var todos = { 22 | 'items': items, 23 | addItem: function(title){ 24 | items.$add({ 25 | 'title': title, 26 | 'finished': false 27 | }); 28 | }, 29 | setFinished: function(item, newV){ 30 | item.finished = newV; 31 | items.$save(item); 32 | } 33 | } 34 | 35 | return todos; 36 | 37 | }]); --------------------------------------------------------------------------------