Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('inparty.controllers', [])
- .controller('AppCtrl', function($scope, $ionicModal, $timeout) {
- // Form data for the login modal
- $scope.loginData = {};
- // Create the login modal that we will use later
- $ionicModal.fromTemplateUrl('templates/login.html', {
- scope: $scope
- }).then(function(modal) {
- $scope.modal = modal;
- });
- // Triggered in the login modal to close it
- $scope.closeLogin = function() {
- $scope.modal.hide();
- };
- // Open the login modal
- $scope.login = function() {
- $scope.modal.show();
- };
- // Perform the login action when the user submits the login form
- $scope.doLogin = function() {
- console.log('Doing login', $scope.loginData);
- // Simulate a login delay. Remove this and replace with your login
- // code if using a login system
- $timeout(function() {
- $scope.closeLogin();
- }, 1000);
- };
- })
- .controller('PlaylistsCtrl', function($scope,$http) {
- $scope.dados = Array();
- $http.get("js/dados.php").success(function(data){
- $scope.dados = data.dados;
- console.log($scope.dados);
- }).error(function(data){
- alert("Error...");
- console.log(data);
- });
- })
- .controller('PlaylistCtrl', function($scope, $stateParams) {
- var idParaEncontrar = $stateParams.id;
- console.log(idParaEncontrar);
- var objectoEncontrado = undefined;
- for(var i = 0; i < $scope.dados.length: ++i){
- if($scope.dados[i].id === idParaEncontrar) {
- objectoEncontrado = $scope.dados[id];
- break;
- }
- }
- if(objectoEncontrado !== undefined) {
- console.log("objecto encontrado")
- }
- });
- angular.module('inparty', ['ionic', 'inparty.controllers','ngRoute'])
- .run(function($ionicPlatform) {
- $ionicPlatform.ready(function() {
- // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
- // for form inputs)
- if (window.cordova && window.cordova.plugins.Keyboard) {
- cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
- }
- if (window.StatusBar) {
- // org.apache.cordova.statusbar required
- StatusBar.styleDefault();
- }
- });
- })
- .config(function($stateProvider, $urlRouterProvider) {
- $stateProvider
- .state('app', {
- url: "/app",
- abstract: true,
- templateUrl: "templates/menu.html",
- controller: 'AppCtrl'
- })
- .state('app.search', {
- url: "/search",
- views: {
- 'menuContent': {
- templateUrl: "templates/search.html"
- }
- }
- })
- .state('app.browse', {
- url: "/browse",
- views: {
- 'menuContent': {
- templateUrl: "templates/browse.html"
- }
- }
- })
- .state('app.playlists', {
- url: "/playlists",
- views: {
- 'menuContent': {
- templateUrl: "templates/playlists.html",
- controller: 'PlaylistsCtrl'
- }
- }
- })
- .state('app.single', {
- url: "/playlists/:id",
- views: {
- 'menuContent': {
- templateUrl: "templates/playlist.html",
- controller: 'PlaylistCtrl'
- }
- }
- });
- // if none of the above states are matched, use this as the fallback
- $urlRouterProvider.otherwise('/app/playlists');
- });
- var inpartyControllers = angular.module('inparty.controllers', []);
- angular.module('inparty', ['ionic', 'inparty.controllers','ngRoute'])
- .run(function($ionicPlatform) {
- // Seu código continua aqui.
- inpartyControllers
- .controller('AppCtrl', function($scope, $ionicModal, $timeout) {
- // Form data for the login modal
- $scope.loginData = {};
- // Seu código continua aqui.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement