mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
HN App kind of working
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
import {Promise} from 'angular2/src/facade/async';
|
import {Promise} from 'angular2/src/facade/async';
|
||||||
console.log(Promise);
|
|
||||||
|
|
||||||
var APIUrl = 'https://hacker-news.firebaseio.com/v0/';
|
var APIUrl = 'https://hacker-news.firebaseio.com/v0/';
|
||||||
|
|
||||||
export class HackerNewsClient {
|
export class HackerNewsClient {
|
||||||
constructor() {
|
constructor() {
|
||||||
//this.fb = new Firebase(APIUrl);
|
//this.fb = new Firebase(APIUrl);
|
||||||
|
@ -1,22 +1,20 @@
|
|||||||
import {NgElement} from 'angular2/angular2';
|
import {bootstrap, ElementRef} from 'angular2/angular2'
|
||||||
import {bootstrap} from 'angular2/angular2'
|
|
||||||
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
|
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
|
||||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||||
|
|
||||||
import {bind} from 'angular2/di';
|
import {Nav, HeaderTemplate, Toolbar, Content} from 'ionic/ionic';
|
||||||
import {Content, Nav, NavPane} from 'ionic/ionic';
|
|
||||||
|
|
||||||
import {HackerNews} from 'hn';
|
import {HackerNews} from './hn';
|
||||||
import {HNTopStories} from 'pages/top';
|
import {HNTopStories} from './pages/top';
|
||||||
|
|
||||||
@Component({ selector: 'ion-app' })
|
@Component({ selector: 'ion-app' })
|
||||||
@View({
|
@View({
|
||||||
templateUrl: 'main.html',
|
templateUrl: 'main.html',
|
||||||
directives: [Content, Nav, NavPane]
|
directives: [Nav, Content, HeaderTemplate, Toolbar]
|
||||||
})
|
})
|
||||||
export class IonicApp {
|
export class IonicApp {
|
||||||
constructor(
|
constructor(
|
||||||
@NgElement() element:NgElement
|
elementRef: ElementRef
|
||||||
) {
|
) {
|
||||||
console.log('IonicApp start: HackerNews', HackerNews)
|
console.log('IonicApp start: HackerNews', HackerNews)
|
||||||
|
|
||||||
@ -27,4 +25,3 @@ export class IonicApp {
|
|||||||
export function main() {
|
export function main() {
|
||||||
bootstrap(IonicApp);
|
bootstrap(IonicApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,2 @@
|
|||||||
<!--
|
|
||||||
<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script>
|
|
||||||
-->
|
|
||||||
<ion-nav [initial]="splashPage">
|
<ion-nav [initial]="splashPage">
|
||||||
</ion-nav>
|
</ion-nav>
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
<ion-view view-title="Top">
|
<ion-view view-title="Top">
|
||||||
<ion-content>
|
<ion-content>
|
||||||
|
|
||||||
<button pop>Back</button>
|
<button pop>Back</button>
|
||||||
<button (click)="throwMe()">xxxx</button>
|
|
||||||
Loaded {{stories.length}} stories
|
|
||||||
<ion-list>
|
<ion-list>
|
||||||
<ion-item *for="#story of stories">
|
|
||||||
|
<item *ng-for="#story of stories">
|
||||||
{{story.title}}
|
{{story.title}}
|
||||||
</ion-item>
|
</item>
|
||||||
|
|
||||||
</ion-list>
|
</ion-list>
|
||||||
|
|
||||||
</ion-content>
|
</ion-content>
|
||||||
</ion-view>
|
</ion-view>
|
||||||
|
@ -1,23 +1,25 @@
|
|||||||
|
import {NgFor, ElementRef, bootstrap} from 'angular2/angular2';
|
||||||
|
|
||||||
import {For, Ancestor, Descendent, Parent, NgElement, Component, View, bootstrap} from 'angular2/angular2';
|
import {Ancestor} from 'angular2/src/core/annotations_impl/visibility';
|
||||||
import {PushToNav, Content, Nav, NavPane, List, Item} from 'ionic/ionic';
|
|
||||||
|
|
||||||
import {HackerNews} from 'hn'
|
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
|
||||||
|
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||||
|
|
||||||
@Component({ selector: 'top-stories' })
|
import {Content, Nav, List, Item} from 'ionic/ionic';
|
||||||
|
|
||||||
|
import {HackerNews} from '../hn'
|
||||||
|
|
||||||
|
console.log('Angular directives', NgFor, Content, List, Item);
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'top-stories'
|
||||||
|
})
|
||||||
@View({
|
@View({
|
||||||
templateUrl: 'pages/top.html',
|
templateUrl: 'pages/top.html',
|
||||||
directives: [Content, For, List, Item, PushToNav]
|
directives: [Content, NgFor, List, Item]
|
||||||
})
|
})
|
||||||
export class HNTopStories {
|
export class HNTopStories {
|
||||||
constructor(@Ancestor() viewport: Nav) {//, @Ancestor() app: HNApp) {
|
constructor() {
|
||||||
console.log('TOP STORIES', 'Ancestor', viewport);
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.throwMe = function() {
|
|
||||||
throw new Error('stack test from throwMe');
|
|
||||||
};
|
|
||||||
|
|
||||||
this.stories = [{
|
this.stories = [{
|
||||||
by: "FatalLogic",
|
by: "FatalLogic",
|
||||||
@ -31,35 +33,27 @@ export class HNTopStories {
|
|||||||
type: "story",
|
type: "story",
|
||||||
url: "http://minusbat.livejournal.com/180556.html"
|
url: "http://minusbat.livejournal.com/180556.html"
|
||||||
}];
|
}];
|
||||||
|
return;
|
||||||
|
|
||||||
var APIUrl = 'https://hacker-news.firebaseio.com/v0';
|
var APIUrl = 'https://hacker-news.firebaseio.com/v0';
|
||||||
this.fb = new window.Firebase(APIUrl);
|
|
||||||
|
|
||||||
this.fb = new window.Firebase(APIUrl);
|
console.log('FIREBASE', window.Firebase);
|
||||||
this.fb.child('topstories').limitToFirst(20).once('value', (snapshot) => {
|
|
||||||
|
|
||||||
let items = snapshot.val();
|
this.fb = new window.Firebase(APIUrl);
|
||||||
|
this.fb.child('topstories').limitToFirst(20).once('value', (snapshot) => {
|
||||||
|
|
||||||
console.log('Fetched', items.length, 'items');
|
let items = snapshot.val();
|
||||||
|
|
||||||
for(var itemID of items) {
|
console.log('Fetched', items.length, 'items');
|
||||||
|
|
||||||
this.fb.child("item").child(itemID).on('value', (data) => {
|
for(var itemID of items) {
|
||||||
//setTimeout(() => {
|
|
||||||
//console.log('SUB THIS', this);
|
|
||||||
//console.log(itemID, data.val());
|
|
||||||
//console.log('ADDED');
|
|
||||||
//self.stories.push(data.val());
|
|
||||||
//throw new Error("stack test");
|
|
||||||
debugger;
|
|
||||||
console.log('GOT ITEM', data.val());
|
|
||||||
self.stories.push({title: 'asdf'});
|
|
||||||
//});
|
|
||||||
|
|
||||||
//console.log(data.val());
|
this.fb.child("item").child(itemID).on('value', (data) => {
|
||||||
});
|
console.log('GOT ITEM', data.val());
|
||||||
}
|
this.stories.push(data.val());
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//doStuffEnd
|
//doStuffEnd
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
<!-- web animations polyfill for non-chrome browsers -->
|
<!-- web animations polyfill for non-chrome browsers -->
|
||||||
<script src="/polyfills/web-animations.min.js"></script>
|
<script src="/polyfills/web-animations.min.js"></script>
|
||||||
|
<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Reference in New Issue
Block a user