Skip to content

Instantly share code, notes, and snippets.

@giorgiofellipe
Created September 18, 2015 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giorgiofellipe/4c275218bbe0d0ea546d to your computer and use it in GitHub Desktop.
Save giorgiofellipe/4c275218bbe0d0ea546d to your computer and use it in GitHub Desktop.
Guia - DEMO Ionic App
1. Copiar .json pra pasta www
2. Instalar angular-resource
2.1 bower install angular-resource
2.2 <script src="lib/angular-resource/angular-resource.min.js"></script> no index.html
2.3 criar module services
angular.module('starter.services', ['ngResource'])
.factory('musicList', function($resource) {
return $resource('music.json', {}, {
'query': {method:'GET', isArray:true}
});
});
2.4 <script src="js/services.js"></script> no index.html
2.5 injetar modulo no app
3. Carregar playlists
3.1 Ajustar playlists.html: add quantidade de musicas e link passando $index
3.2 PlaylistsCtrl $scope.playlists = musicList.query();
4. Carregar songs
4.1 Ajustar playlist.html: add duraçao das musicas
4.2 PlaylistCtrl
$scope.songs = [];
musicList.query(function(response) {
angular.forEach(response, function (item, index) {
if (index == $stateParams.playlistId) {
$scope.songs = item.songs;
}
});
});
5. Adicionar Botão de Share
5.1 <ion-option-button class="button-positive" ng-click="showShareOptions()">Share</ion-option-button> playlists.html
5.2 PlaylistsCtrl
$scope.showShareOptions = function() {
var hideSheet = $ionicActionSheet.show({
buttons: [
{text: 'Facebook'},
{text: 'Twitter'},
{text: 'Whatsapp'}
],
titleText: 'Share your album',
cancelText: 'Cancel',
cancel: function () {
},
buttonClicked: function (index) {
return true;
}
});
$timeout(function () {
hideSheet();
}, 2000);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment