Aug 4, 2015

OnsenUI: Change tab without pressing ons-tabber's ons-tab (with AngularJs)

I have been searching around for changing tab with AngularJs $scope function, without pressing on the ons-tabber's tab.
This function will do the trick setActiveTab()
First, you have to specify name for the tabbar,
(eg. ons-tabbar[var="myTabbar"])

use setActiveTab() with index (just like array, start from 0) for myTabbar:
myTabbar.setActiveTab(1) for my case below.

AngularJs

var app = angular.module('app', ['onsen']);

app.controller('myCtrl', ['$scope', function($scope) {
  $scope.goHome = function() {
    // setActiveTab(index, options)
    myTabbar.setActiveTab(1, {animation: 'fade'});
  };
}]);

Html

<ons-page ng-controller="myCtrl">
  <ons-toolbar>
    <div class="right">
      Toolbar - myCtrl
    </div>
  </ons-toolbar>
  
  <ons-button ng-click="goHome()">Go Home</ons-button>

  <ons-tabbar var="myTabbar">
    <ons-tab active="true" icon="ion-images" label="App" no-reload="" page="app.html" persistent=""></ons-tab>
    <ons-tab icon="fa-user" label="Home" no-reload="" page="home.html" persistent=""></ons-tab>
  </ons-tabbar>
</ons-page>

Summary
The main part:

  • use variable name for ons-tabbar
  • use setActiveTab(index) with the tabbar variable name to redirect

Aug 2, 2015

The meaning of OAuth redirect URIs

Because of my limited understanding about the technical term used in Facebook Developer,
I have been struggling hard to implement even the login provided by Facebook. 

SO I'm writing this for future reference:
Valid OAuth redirect URIs = the URL (or link) of where your Facebook login placed.

Meaning of OAuth redirect URIs
Meaning of OAuth redirect URIs

Eg. 
if your Facebook placed under the URL http://localhost/facebook/login/
then you can insert either http://localhost/ or http://localhost/facebook/login/ (exact URL) in the Valid OAuth redirect URIs input box. 

Jun 3, 2015

AngularJs UI-Router conditional Otherwise link

For easier handling of redirection of $state,
when our angularJs app handling an unknown $state name,
it'll refer to $urlRouterProvider.otherwise("/"); which have to be written inside "config()".
assuming your angular app is declared as below:

var app = angular.module([]);

app.config(['$urlRouterProvider', function($urlRouterProvider) {
  $urlRouterProvider.otherwise(function($injector, $location) {
    var AuthService= $injector.get("AuthService");
    if (AuthService.isLoggedIn()) {
      return "main";
    } else {
      return "login";
    }
  });
}]);
this allow your otherwise become dynamic depend on the login status of a user. In the code above, AuthService is an example authentication service to help determine if a user is logged in.

May 27, 2015

You just simply cannot change the date format in HTML5 date type input

By referring quite number of sites,
and did quite some number of stubborn trials...

the conclusion is that you
CANNOT CHANGE DATE FORMAT FOR HTML5 DATE TYPE INPUT

thanks a lot to the solid references:
Is there any way to change input type=“date” format?
Example provided in fiddle 

further reading, for quick & easy learning:
The date Type

Mar 23, 2014

raspberry pi for dummy: WPA_SUPPLICANT: /SBIN/WPA_SUPPLICANT DAEMON FAILED TO START

Monday, 27 March 2017 UPDATE:
- please refer to this official Raspberry Pi Wifi configuration documentation

After you have the USB Wifi dongle plugged into your RPI, you can scan wifi sign near you with
sudo iwlist wlan0 scan 
command (if this work, that mean you are close to setup wifi successfully)

Finally, if you haven't added any network config in your wpa_supplicant.conf (/etc/wpa_supplicant/wpa_supplicant.conf) insert wifi detail using:
wpa_passphrase "your wifi SSID" "your wifi password" >> /etc/wpa_supplicant/wpa_supplicant.conf

Note: please refer official link attached above for detailed explanation.


If you face problems stated below:
- WPA_SUPPLICANT: /SBIN/WPA_SUPPLICANT DAEMON FAILED TO START


You may first look at this Setting up Wifi (EDIMAX) on Raspberry Pi,
if you're still fail to configure a successful connection to your access point (AP or wifi router),
please remove the quote symbol to your psk value like this in your wpa_supplicant.conf:
network={
    ssid="Your SSID Here"
    key_mgmt=WPA-PSK
    psk=YourPresharedKeyHereWithoutQuote
}
get your PSK value from WireShark WPA-PSK Generator.

Once done:
apply commands and restart network or your RPI (sudo reboot):
sudo service networking restart
sudo ifup wlan0 (or sudo ifdown wlan0 then sudo ifup wlan0)

I wrote this because I saw too many tutorial out there didn't mention/emphasize about removing the quote symbol for psk value.
examples
Circled quotes symbols should not be around your psk value

wireless setup command reference: Useful Linux Wireless Commands