Commit 65d05cc15e69463edb67d4e2f63eff2deeb1a699
1 parent
80d1e57aa5
Exists in
master
and in
1 other branch
updated deck
Showing 2 changed files with 77 additions and 23 deletions Inline Diff
scripts/DeckController.js
View file @
65d05cc
var app = angular.module('flashy.DeckController', ['ui.router']); | 1 | 1 | var app = angular.module('flashy.DeckController', ['ui.router']); | |
2 | 2 | |||
app.controller('DeckController', ['$scope', function($scope) { | 3 | 3 | app.controller('DeckController', ['$scope', '$http', function($scope, $http) { | |
$scope.hello = function() { | 4 | 4 | ||
alert('hello'); | 5 | 5 | ||
}; | 6 | 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 | }]); | |
8 | 45 | |||
templates/deck.html
View file @
65d05cc
<!DOCTYPE html> | 1 | 1 | <div class="row"> | |
<html ng-app="flashy"> | 2 | |||
<head> | 3 | |||
4 | ||||
<link rel="stylesheet" href="styles/bootstrap-3.3.4-dist/css/bootstrap.css" /> | 5 | |||
<link rel="stylesheet" href="flashy.css" /> | 6 | |||
7 | 2 | |||
</head> | 8 | 3 | <div ng-repeat="card in cards"> | |
<body ng-controller="DeckController"> | 9 | |||
10 | 4 | |||
<button type="button" ng-click="hello()">SUPPPP</button> | 11 | 5 | <div class="col s6"> | |
12 | 6 | |||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script> | 13 | 7 | <div class="card"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.14/angular-ui-router.js"></script> | 14 | |||
<script src="/app/config.js"></script> | 15 | |||
<!--<script src="controller.js"></script>--> | 16 | |||
17 | 8 | |||
<script src="DeckController.js"></script> | 18 | |||
</body> | 19 | |||
</html> | 20 | |||
21 | 9 | |||
22 | 10 | |||
<script src="viewDeckController.js"></script> | 23 | 11 | <div class="card-image"> | |
</body> | 24 | 12 | <span class="card-title">{{card.title}}</span> | |
</html> | 25 | 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 |