Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ angular.module('starter', [
'supermodular.home',
'supermodular.map',
'supermodular.wordpress',
'supermodular.firebase',
'supermodular.menu',
'supermodular.elements',
'supermodular.popover-menu',
Expand Down
28 changes: 14 additions & 14 deletions app/scripts/firebase/firebase-article.controller.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
(function() {
'use strict';

angular
.module('supermodular.firebase')
.controller('FirebaseArticleController', FirebaseArticleController);

.module('supermodular.firebase')
.controller('FirebaseArticleController', FirebaseArticleController);
FirebaseArticleController.$inject = ['$stateParams', 'firebaseService'];

/* @ngInject */
function FirebaseArticleController($stateParams, firebaseService) {
var articleId = parseInt($stateParams.articleId, 10);

var guid = $stateParams.guid;
var vm = angular.extend(this, {
article: null,
});

function activate() {
loadArticle();
}
activate();

// ********************************************************************

function loadArticle() {
// firebaseService.getArticle(articleId)
// .then(function(article) {
// vm.article = article;
// });
firebaseService.getArticle(guid)
.then(function(article) {
vm.article = article;
});
}
}
})();
28 changes: 14 additions & 14 deletions app/scripts/firebase/firebase-articles.controller.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
(function() {
'use strict';

angular
.module('supermodular.firebase')
.controller('FirebaseArticlesController', FirebaseArticlesController);

.module('supermodular.firebase')
.controller('FirebaseArticlesController', FirebaseArticlesController);
FirebaseArticlesController.$inject = ['$state', 'firebaseService'];

/* @ngInject */
function FirebaseArticlesController($state, firebaseService) {
var vm = angular.extend(this, {
articles: [],
navigate: navigate
});

function activate() {
getArticles();
}
activate();

// ********************************************************************

function getArticles() {
firebaseService.getArticles()
.then(function(articles) {
vm.articles = articles;
});
.then(function(articles) {
vm.articles = articles;
});
}

function navigate(articleId) {
$state.go('app.firebase-article', { articleId: articleId });
function navigate(guid) {
$state.go('app.firebase-article', { guid: guid });
}
}
})();
2 changes: 1 addition & 1 deletion app/scripts/firebase/firebase-articles.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ion-content>
<div ng-repeat="article in vm.articles">

<div class="card" ng-click="vm.navigate(article.id)">
<div class="card" ng-click="vm.navigate(article.guid)">
<div class="item item-text-wrap item-thumbnail-left">
<img ng-src="{{article.thumb}}">
<h2>{{article.title}}</h2>
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/firebase/firebase.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
})
.state('app.firebase-article', {
url: '/firebase-articles/:articleId',
url: '/firebase-articles/:guid',
views: {
'menuContent': {
templateUrl: 'scripts/firebase/firebase-article.html',
Expand Down
37 changes: 19 additions & 18 deletions app/scripts/firebase/firebase.service.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
(function() {
'use strict';

angular
.module('supermodular.firebase')
// DB service
.factory('db', [function() {
return new Firebase('https://business-directory.firebaseio.com/')
}])
// Firebase service
.factory('firebaseService', firebaseService);

.module('supermodular.firebase')
// DB service
.factory('db', [function() {
return new Firebase('https://business-directory.firebaseio.com/');
}])
// Firebase service
.factory('firebaseService', firebaseService);
firebaseService.$inject = ['db', '$firebaseArray', '$firebaseObject'];

/* @ngInject */
function firebaseService(db, $firebaseArray, $firebaseObject) {

var service = {
getArticles: getArticles,
getArticle: getArticle
};
return service;

////////////////

function getArticles() {
var query = db.child('news');
return $firebaseArray(query).$loaded().then(initArray);
}

function getArticle(articleId) {
function getArticle(guid) {
// TODO: Fetch and display a particular article
var article = {};
return article;
var query = db.child('news/'+guid);
return $firebaseObject(query).$loaded();
}

function initItem(item) {
return angular.extend({}, item, {
guid: item.$id
});
}

function initArray(array) {
return _.map(array, initItem);
}
Expand Down
6 changes: 5 additions & 1 deletion app/scripts/home/menu-items.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
title: 'Wordpress',
path: 'wordpress-articles',
icon: 'ion-social-wordpress'
}, {
},{
title: 'Firebase',
path: 'firebase-articles',
icon: 'ion-android-globe'
},{
title: 'Elements',
path: 'elements',
icon: 'ion-android-checkbox-outline'
Expand Down
6 changes: 3 additions & 3 deletions install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ ionic state restore
:: Add target platform
::
:: Comment out the platform(s) your system supports
::
grunt platform:add:ios
:: grunt platform:add:android
::grunt platform:add:ios
::
grunt platform:add:android

::
:: Build the project and generate the cordova directory (www)
Expand Down
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@
},
"scripts": {
"test": "grunt test",
"//": "Post installation.",
"//": "Uncomment the next line to enable post install script.",
"//": "There is always the option to run it manually.",
"//": { "postinstall": "./install.sh" },
"//": { "postinstall": "./install.bat" }
"//": {
"postinstall": "./install.bat"
}
},
"cordovaPlatforms": [],
"cordovaPlugins": [
Expand All @@ -73,6 +71,7 @@
},
"cordova-plugin-network-information",
"cordova-plugin-whitelist",
"cordova-plugin-transport-security"
"cordova-plugin-transport-security",
"cordova-plugin-inappbrowser"
]
}
}