Fun stuff

This commit is contained in:
Max Lynch
2015-04-27 10:30:35 -05:00
parent c6f2f49a43
commit f4905ee5b7
8 changed files with 79 additions and 2 deletions

View File

@@ -0,0 +1,13 @@
export class HackerNews {
constructor() {
this.fb = new Firebase('https://hacker-news.firebaseio.com/v0');
this.getPosts();
}
getPosts() {
console.log('GETTING POSTS');
this.fb.child('topstories').on('value', function(snapshot) {
console.log(snapshot.val());
});
}
}

View File

@@ -0,0 +1,3 @@
<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script>
<ion-nav [initial]="splashPage">
</ion-nav>

View File

@@ -0,0 +1,28 @@
import {Descendent, NgElement, Component, View as NgView, bootstrap} from 'angular2/angular2';
import {View, Content, Nav, NavPane} from 'ionic/ionic';
import {HackerNews} from 'hn';
import {HNSplashPage} from 'pages/splash';
@Component({ selector: '[ion-app]' })
@NgView({
templateUrl: 'main.html',
directives: [View, Content, Nav, NavPane]
})
class IonicApp {
constructor(
@NgElement() element:NgElement
) {
console.log('IonicApp start: HackerNews')
this.splashPage = HNSplashPage
// Timeout so Firebase can be resolved
setTimeout(() => {
this.hn = new HackerNews();
});
}
}
bootstrap(IonicApp)

View File

@@ -0,0 +1,3 @@
<div>
<h1>That's so <i>HACKER NEWS</i></h1>
</div>

View File

@@ -0,0 +1,13 @@
import {Descendent, Parent, NgElement, Component, View as NgView, bootstrap} from 'angular2/angular2';
import {View, Content, Nav, NavPane} from 'ionic/ionic';
@Component({ selector: 'splash-page' })
@NgView({
templateUrl: 'pages/splash.html',
directives: [View, Content]
})
export class HNSplashPage {
constructor(@Parent() viewport: Nav) {
//window.navPane = navPane;
}
}

View File

@@ -1,6 +1,6 @@
<ion-view nav-title="Pull to refresh">
<ion-content ion-refresher>
<ion-content ion-refresher (refreshing)="doRefresh()">
<div id="counter"></div>

View File

@@ -17,6 +17,10 @@ class IonicApp {
) {
console.log('IonicApp Start')
}
doRefresh() {
console.log('DOREFRESH')
}
}
bootstrap(IonicApp)

View File

@@ -1,4 +1,4 @@
import {NgElement, Decorator, Component, View as NgView, PropertySetter} from 'angular2/angular2';
import {NgElement, EventEmitter, Decorator, Component, View as NgView, PropertySetter} from 'angular2/angular2';
@Decorator({
selector: '[ion-refresher]'
@@ -10,10 +10,23 @@ export class Refresher {
this.domElement = element.domElement;
this.domElement.classList.add('content');
this.refreshEvent = new EventEmitter('refreshing');
console.log(this.domElement);
this.domElement.children[0].addEventListener('scroll', function(e) {
console.log('CONTENT: scroll', e.target.scrollTop);
});
setTimeout(() => {
this.refresh()
}, 1000);
}
refresh() {
console.log('REFRESH');
this.refreshEvent.next({
data: 'blah'
});
}
}