This commit is contained in:
Max Lynch
2015-04-29 15:02:42 -05:00
parent ee678856e9
commit 2715e50988
7 changed files with 67 additions and 18 deletions

View File

@ -29,6 +29,7 @@ export class LoginPage {
Log.log('Doing login')
event.preventDefault();
console.log(this.loginForm.value);
//this.viewport.push(SecondPage)
}
doSignup(event) {
@ -155,12 +156,23 @@ class IonicApp {
setTimeout(() => {
var nav = window.navPane;
var route = new Router()
var route = Router;//new Router()
/*
route.map('login', {
url: '/login',
paramResolver(urlParts) {
return Login(urlParts.id);
}
})
*/
route.on('/login', (data) => {
nav.push(LoginPage, null, {
animate: false
})
})
route.on('/post/:id', (data) => {

View File

@ -1,7 +1,7 @@
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 {
constructor() {
this.fb = new Firebase(APIUrl);

View File

@ -1,8 +1,10 @@
<ion-view view-title="Top">
<ion-content>
<!--<h1>That's so <i>HACKER NEWS</i></h1>-->
<button pop>Back</button>
<button (click)="throwMe()">xxxx</button>
Loaded {{stories.length}} stories
<ion-list>
<ion-item *for="#story of stories" push-to="single">
<ion-item *for="#story of stories">
{{story.title}}
</ion-item>
</ion-list>

View File

@ -9,8 +9,14 @@ import {HackerNews} from 'hn'
directives: [View, Content, For, List, Item, PushToNav]
})
export class HNTopStories {
constructor(@Parent() viewport: Nav) {//, @Ancestor() app: HNApp) {
console.log('TOP STORIES');
constructor(@Ancestor() viewport: Nav) {//, @Ancestor() app: HNApp) {
console.log('TOP STORIES', 'Ancestor', viewport);
var self = this;
this.throwMe = function() {
throw new Error('stack test from throwMe');
};
this.stories = [{
by: "FatalLogic",
@ -25,23 +31,39 @@ export class HNTopStories {
url: "http://minusbat.livejournal.com/180556.html"
}];
return;
var APIUrl = 'https://hacker-news.firebaseio.com/v0';
this.fb = new Firebase(APIUrl);
var s = document.createElement('script');
s.src = 'https://cdn.firebase.com/js/client/2.2.4/firebase.js';
s.async = true;
s.onload = doStuff.bind(this);
document.head.appendChild(s);
console.log('loading firebase');
function doStuff() {
console.log('done loading firebase');
this.fb = new window.Firebase(APIUrl);
this.fb.child('topstories').limitToFirst(20).once('value', (snapshot) => {
let items = snapshot.val();
console.log('Fetched', items.length, 'items');
debugger;
for(var itemID of items) {
this.fb.child("item").child(itemID).on('value', (data) => {
setTimeout(() => {
console.log(itemID, data.val());
console.log('ADDED');
this.stories.push(data.val());
});
//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());
});
@ -49,6 +71,9 @@ export class HNTopStories {
});
//doStuffEnd
}
/*
HackerNews.getTopStories((val) => {
new Promise((resolve, reject) => {

View File

@ -23,3 +23,11 @@ export class PushToNav {
console.log('PUSH TO NAV', this.navTag);
}
}
@Decorator({
selector: '[href]'
})
export class HrefNav {
constructor(element: NgElement) {
}
}

View File

@ -1,5 +1,4 @@
export class Router {
export class RouterSingleton {
constructor() {
this.routes = []
}
@ -18,7 +17,7 @@ export class Router {
if(routeParams !== false) {
route.exec(this.buildRouteParams(routeParams));
this.emit(route.url)
this.emit(route.url);
return
}
}
@ -116,3 +115,5 @@ export class Route {
}
}
var Router = new RouterSingleton();
export { Router };

View File

@ -34,7 +34,8 @@ module.exports = {
'angular2.js',
'angular2-di.js',
'ionic2.js',
'https://cdn.firebase.com/js/client/2.2.4/firebase.js'
// 'https://cdn.firebase.com/js/client/2.2.4/firebase.js'
// 'https://cdn.firebase.com/js/client/2.2.4/firebase-debug.js'
],
traceurOptions: {