angular.module('flashy.FeedController', ['ui.router']). controller('FeedController', ['$scope', '$stateParams', '$state', '$http', function($scope, $stateParams, $state, $http) { console.log('Hello from feed'); sectionId = $stateParams.sectionId; $scope.cards = []; $scope.cards[0] = {'id': 1, 'title': 'title1', 'content': 'abc'}; $scope.cards[1] = {'id': 2, 'title': 'title2', 'content': 'xyz'}; $scope.cards[2] = {'id': 2, 'title': 'title3', 'content': 'qwe'}; $http.get('/api/sections/' + sectionId + '/flashcards/'). success(function(data) { for (var i = 0; i < data.length; i++) { cards.push({'title': data[i].title, 'content': data[i].content}); } }). error(function(err) { console.log('no'); }); $scope.viewDeck = function() { $state.go('deck'); console.log('go to deck'); }; $scope.pullCard = function(card) { var index = $scope.cards.indexOf(card); console.log($scope.cards[index]); }; $scope.pushCard = function() { console.log('make! card content:' + $scope.text); var pushed = new Date(Date.now()); console.log(pushed.toString()); // attempt to make card :( $http.post('/api/flashcards/', {'text': $scope.text, 'pushed': pushed, 'mask': []}). success(function(data) { console.log('No way, really?'); }). error(function(error) { console.log('haha, n00b'); }); $scope.text = ''; }; $scope.flashcard = 'hi i am a flashcard. I need to be really long and awesome I ain\'t ' + 'know how long I am right now. Is it good enough now?????????? Howz about now???'; $scope.text = ''; $(document).ready(function() { // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered $('.modal-trigger').leanModal({ dismissible: true, // Modal can be dismissed by clicking outside of the modal opacity: 0, // Opacity of modal background in_duration: 300, // Transition in duration out_duration: 200, // Transition out duration /*ready: function() { alert('Ready'); }, // Callback for Modal open complete: function() { alert('Closed'); } // Callback for Modal close*/ } ); }); }]);