Commit 65d05cc15e69463edb67d4e2f63eff2deeb1a699

Authored by Kevin Mach
1 parent 80d1e57aa5

updated deck

Showing 2 changed files with 77 additions and 23 deletions Side-by-side Diff

scripts/DeckController.js View file @ 65d05cc
1 1 var app = angular.module('flashy.DeckController', ['ui.router']);
2 2  
3   -app.controller('DeckController', ['$scope', function($scope) {
4   - $scope.hello = function() {
5   - alert('hello');
6   - };
  3 +app.controller('DeckController', ['$scope', '$http', function($scope, $http) {
  4 +
  5 +
  6 +
  7 + $scope.cards = [];
  8 +
  9 +
  10 +
  11 + $scope.cards[0] = { "id": 1, "title": "title1", "content": "abc" };
  12 + $scope.cards[1] = { "id": 2, "title": "title2", "content": "xyz" };
  13 + $scope.cards[2] = { "id": 2, "title": "title3", "content": "qwe" };
  14 +
  15 +
  16 + $scope.removeCard = function (item) {
  17 +
  18 +
  19 + var index = $scope.cards.indexOf(item);
  20 +
  21 + $scope.cards.splice(index, 1);
  22 +
  23 + alert("removed card");
  24 + }
  25 +
  26 +
  27 + $http.get('/api/sections/{pk}/deck').
  28 + success(function (data) {
  29 +
  30 +
  31 + for (var i = 0; i < data.length; i++) {
  32 + cards.push({ "title": data[i].title, "content": data[i].content });
  33 + }
  34 + }).
  35 + error(function (data) {
  36 +
  37 + console.log("no cards?!!");
  38 +
  39 + });
  40 +
  41 +
  42 +
  43 +
7 44 }]);
templates/deck.html View file @ 65d05cc
1   -<!DOCTYPE html>
2   -<html ng-app="flashy">
3   - <head>
4   -
5   - <link rel="stylesheet" href="styles/bootstrap-3.3.4-dist/css/bootstrap.css" />
6   - <link rel="stylesheet" href="flashy.css" />
  1 +<div class="row">
7 2  
8   - </head>
9   - <body ng-controller="DeckController">
  3 + <div ng-repeat="card in cards">
10 4  
11   - <button type="button" ng-click="hello()">SUPPPP</button>
  5 + <div class="col s6">
12 6  
13   - <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script>
14   - <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.14/angular-ui-router.js"></script>
15   - <script src="/app/config.js"></script>
16   - <!--<script src="controller.js"></script>-->
  7 + <div class="card">
17 8  
18   - <script src="DeckController.js"></script>
19   - </body>
20   -</html>
21 9  
22 10  
23   - <script src="viewDeckController.js"></script>
24   - </body>
25   -</html>
  11 + <div class="card-image">
  12 + <span class="card-title">{{card.title}}</span>
  13 + </div>
  14 + <div class="card-content">
  15 +
  16 +
  17 +
  18 + <p>
  19 + {{card.content}}
  20 +
  21 +
  22 + </p>
  23 + </div>
  24 +
  25 +
  26 +
  27 + <div class="card-action">
  28 +
  29 +
  30 + <button type="button" class="waves-effect waves-light btn" ng-click="removeCard()">Remove</button>
  31 +
  32 +
  33 + </div>
  34 +
  35 + </div>
  36 +
  37 + </div>
  38 +
  39 +
  40 + </div>
  41 +</div>
  42 +