Created
January 18, 2015 22:22
-
-
Save segphault/f648f6a491a129acb22d to your computer and use it in GitHub Desktop.
Simple iOS app built with NativeScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var application = require("application"); | |
application.mainModule = "app/main"; | |
application.start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require("http"); | |
var Observable = require("data/observable").Observable; | |
var ObservableArray = require("data/observable-array").ObservableArray; | |
var listStories = new ObservableArray(); | |
var feedUrl = "http://newsblur.com/reader/river_stories"; | |
exports.pageLoaded = function(args) { | |
args.object.bindingContext = { | |
stories: listStories | |
}; | |
}; | |
exports.buttonClick = function(args) { | |
http.getJSON(feedUrl).then(function(output) { | |
listStories.push.apply(listStories, output.stories); | |
}); | |
}; | |
exports.itemClick = function(args) { | |
console.log("CLICKED ITEM:", listStories.getItem(args.index).story_title); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Page loaded="pageLoaded"> | |
<ScrollView> | |
<StackPanel> | |
<Button text="Load" click="buttonClick" /> | |
<ListView id="listItems" itemTap="itemClick" items="{{ stories }}"> | |
<ListView.itemTemplate> | |
<Label id="labelItem" textWrap="true" text="{{ story_title }}" /> | |
</ListView.itemTemplate> | |
</ListView> | |
</StackPanel> | |
</ScrollView> | |
</Page> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment