Video Screencast: How to use Framework7 with AngularJS

After posting my experiment of using Framework7 with TypeScript and Angular I get quite some questions from people on how to properly use F7 with Angular, so I made a quick screencast:

How to use Framework7 with AngularJS

About using ajax pages

If you use Framework7’s ajax pages mechanism read my blog post about this and how to get this working with Angular.

Should you use Angular UI router with Framework 7?

If you want to find the answer to this, check out this blog post: Should I use Angular’s ngRouter in Framework7?


How to scroll up by tapping status bar in Cordova/PhoneGap

Holy, moly! This issue has been chasing me for more than 3 years! I’ve always been a passionate Cordova/PhoneGap developer, even if many people don’t like it: I personally think it’s not a bad platform if you got experience and you know what you’re doing.

However, since apps built with Cordova/PhoneGap completely rely on webkit and html, scrolling usually feels a little slow which is the reason why many people use a trick: They blow up a div element to 100% width and height and use -webkit-overflow-scrolling:touch to get smooth momentum scrolling within the div.

Now, this works pretty good but the tradeoff is that you loose the ability to easily scroll up in your app by simply tapping the status bar on the top of the screen in iOS. This is a big usability issue and needs to be fixed imho.

So, here’s the fix:

First, you need to install this plugin: cordova-plugin-statusbar
You can do so by simply opening terminal, cd to your project folder an run:

cordova plugin add cordova-plugin-statusbar

This plugin will fire an event when status bar is tapped. You need to listen to this event in JavaScript:

document.addEventListener("deviceready", function () {
    window.addEventListener("statusTap", function () {
        scrollUp(); // Now, let's implement this, shall we? :D
}, false);

You’re almost there! You only need to programmatically scroll up your container. Let’s assume the container you’re scrolling on and which you applied -webkit-overflow-scrolling:touch on has id “wrapper“.

<div id="wrapper">
    Lots of stuff here to scroll..

So what you want to do is:

var isScrollingUp = false,
    scrollTime = 700; // Adjust scroll speed here. Lower = faster. Higher = slower.
function scrollUp () {
    if (!isScrollingUp){
        var $curpage = $('#wrapper'),
            curpage = $curpage.get(0); = 'hidden';
        isScrollingUp = true;
        $curpage.animate({scrollTop: 0}, scrollTime);
        setTimeout(function () {
            isScrollingUp = false;
        }, scrollTime + 1);
        $timeout(function () {
   = '';
        }, 10);

I know the code ain’t pretty because of all the weird timeout stuff but it magically just works.


I stripped this code snipped off a project of mine and had to do some modifications for this blog post, so I don’t know if everything still works, so please let me know if this did work for you or not.

Why I am still in love with Framework7

Disclaimler: First of all, let me state clear that I am not involved into the Framework7 project. I am not getting paid for this post. This is just my honest, personal opinion as a mobile developer.

Early steps

The first framework I used when I started mobile development was jQueryMobile. I was used to jQuery coming from Desktop programming so I thought: “Hey, it says jQuery, so I guess it must be good”. It sucked balls, just like any other Framework I tried like KendoUI, SenchaTouch or Ionic. They either sucked regarding performance, sucked about look & feel or simply sucked monkey ass ballz! Excuse me for my language but for years I couldn’t believe that it was true that there is no HTML5-framework that can deliver anything close to a native app, so I always believed that it simply wasn’t possible.

And then I discovered Framework7

Oh, boy was I blown away when I saw the first demos for iOS on their website. This was just what I was looking for. The way these apps looked, feeled and performed was 99.9% accurate to what I am used from native apps. I couldn’t believe it and so I tipped my first steps in. I quickly found out that Framework7 was not only easy to use, it just worked™. You create a few lines of HTML markup and boom, that’s it. Framework7 will take care of the rest. The looks, the page transitions all works out of the box. I couldn’t believe it and why hadn’t I heard about it before? I don’t know but since they also released a new Material Design option for Android I am absolutely convinced: This is it. The best framework you could possibly use for mobile app development with HTML5, CSS3 and JavaScript. Throw that all into a PhoneGap/Cordova container and you should be fine.


framework7 demo screenshot


For iPhone open this.
On Android open this.

The future

The biggest problem I see with Framework7 is that it doesn’t get enough attention. For years I didn’t hear anything about it and when I talk to other devs they never saw it before until I show em and they’re all completely blown away.

Also, if you search for “best html5 mobile framework” on Google you will get shitloads of so called comparison websites like “Top 10 mobile frameworks” and barely I see F7 mentioned or even find their main website in the search results. So, if you like F7 and you’d like to support, go tweet about it right now!

I just hope that developers haven’t given up on HTML5 for apps yet. Since the hype of Facebook’s React framework many people seem to transition there.

Oh, boy I need to go back coding. This is so much fun <3

How to set user agent for file_get_html() in dom.php

The problem with file_get_html ()

I really like the Simple HTML DOM Parser for PHP cause of its simplicity but today I encountered the problem of grabbing different HTML for different devices, so I checked the docs but couldn’t find any option how to do it.

So, I dugg into the lib code myself, ready for some manual patching, when I found out that there is actually a way to do this the proper way.

The solution

Let’s assume, you open a connection like this:

$html = file_get_html ($url);

In order to set a user agent for iPhone 5 for example, simply do this:

$opts = array(
    'header'=>"User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53\r\n"
$context = stream_context_create($opts);
$html = file_get_html($url, false, $context);

As you can see, you can even set more headers if you want.

Damn, that was easy, wasn’t it? :-)

How to add dots every 3 digits in currency values with JavaScript

If you’re European like me, you’re probably used to this notation:
€ 366.432 instead of 366,432 or 366432.
In order to get this done in JavaScript you want to do the following:

// Number
var money = 366432;
// Convert to String and add dots every 3 digits
var moneyDots = money.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1.");
// Set in HTML
$('.anywhere').text('€ ' + moneyDots);

Keep in mind that moneyDots is a String from now on! It’s not a number anymore!