mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
Fun stuff
This commit is contained in:
13
ionic/components/app/test/hn/hn.js
Normal file
13
ionic/components/app/test/hn/hn.js
Normal 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());
|
||||
});
|
||||
}
|
||||
}
|
||||
3
ionic/components/app/test/hn/main.html
Normal file
3
ionic/components/app/test/hn/main.html
Normal 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>
|
||||
28
ionic/components/app/test/hn/main.js
Normal file
28
ionic/components/app/test/hn/main.js
Normal 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)
|
||||
|
||||
3
ionic/components/app/test/hn/pages/splash.html
Normal file
3
ionic/components/app/test/hn/pages/splash.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<div>
|
||||
<h1>That's so <i>HACKER NEWS</i></h1>
|
||||
</div>
|
||||
13
ionic/components/app/test/hn/pages/splash.js
Normal file
13
ionic/components/app/test/hn/pages/splash.js
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ class IonicApp {
|
||||
) {
|
||||
console.log('IonicApp Start')
|
||||
}
|
||||
|
||||
doRefresh() {
|
||||
console.log('DOREFRESH')
|
||||
}
|
||||
}
|
||||
|
||||
bootstrap(IonicApp)
|
||||
|
||||
@@ -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'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user