DragandDrop geadded

This commit is contained in:
Carsten Hilmer
2016-10-21 00:54:38 +02:00
parent 1b1998dc17
commit caab200984
7 changed files with 748 additions and 3 deletions

View File

@@ -5,7 +5,7 @@
// the 2nd parameter is an array of 'requires'
// 'starter.services' is found in services.js
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic', 'ngCordova', 'starter.controllers', 'starter.services'])
angular.module('starter', ['ionic', 'ngCordova', 'ngDraggable', 'starter.controllers', 'starter.services'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
@@ -69,6 +69,16 @@ angular.module('starter', ['ionic', 'ngCordova', 'starter.controllers', 'starter
controller: 'Spiel2Ctrl'
}
}
})
.state('tab.spiel3', {
url: '/spiel3',
views: {
'tab-spiel3': {
templateUrl: 'templates/spiel3.html',
controller: 'Spiel3Ctrl'
}
}
});
// if none of the above states are matched, use this as the fallback

View File

@@ -18,6 +18,11 @@ angular.module('starter.controllers', [])
$cordovaMedia.play(media);
}
$scope.starte_spiel3 = function() {
var media = new Media('/android_asset/www/sounds/spiel2.mp3', goto_spiel2, null);
$cordovaMedia.play(media);
}
function goto_spiel1() {
$state.go('tab.spiel1');
}
@@ -25,6 +30,10 @@ angular.module('starter.controllers', [])
function goto_spiel2() {
$state.go('tab.spiel2');
}
function goto_spiel3() {
$state.go('tab.spiel3');
}
})
@@ -259,4 +268,46 @@ $scope.playwait = function(src) {
goto_newspiel();
})
.controller('Spiel3Ctrl', function($scope, $cordovaMedia, $state, $timeout) {
$scope.spiele=[];
$scope.error = false;
var tier = {
id: 1,
bild: 'elefant.jpg',
sound1: 'sound_elefant.mp3',
antwort: ''
};
$scope.spiele.push(tier);
var tier1 = {
id: 2,
bild: 'esel.jpg',
sound1: 'sound_esel.mp3',
antwort: ''
};
$scope.spiele.push(tier1);
var tier2 = {
id: 3,
bild: 'hahn.jpg',
sound1: 'sound_hahn.mp3',
antwort: ''
};
$scope.spiele.push(tier2);
$scope.onDropComplete = function (index, obj, evt) {
var otherObj = $scope.spiele[index];
var otherIndex = $scope.spiele.indexOf(obj);
$scope.spiele[index] = obj;
$scope.spiele[otherIndex] = otherObj;
}
});