Thursday, 15 June 2017

Open Link on Browser in Ionic Framework

To be able to open a link in an Ionic Framework based app, we need to install InAppBrowser plugin. If you use Visual Studio Tools for Apache Cordova, you can open config.xml file and find in Plugins section.

After installing the plugin, we don’t need to pass any new module in the code function constructor. All we need to do is just to call the functions directly like:'', '_system');
// or we can use'', '_system');
_system target is used so that the link will be opened on system's web browser.

In HTML code, we can call like this:
<a href="#" onclick="'', '_system');">my link</a>
Don’t forget to include the ‘http://’ otherwise you will get an error like ‘Cannot display PDF (… cannot be opened).

Thursday, 9 February 2017

Ionic Modal with this Controller

Below is a simple example of using Ionic Modal with this controller (Controller As):
var vm = this;
    . . .
    . . .
    . . .

    /* modal */
    vm.showModal = function () {

    $ionicModal.fromTemplateUrl('my-modal.html', {
        scope: $scope,
        animation: 'slide-in-up'
    }).then(function (modal) {
        vm.modal = modal;

    vm.openModal = function () {;

    vm.closeModal = function () {

    // Clean up the modal
    $scope.$on('$destroy', function () {

    // Execute action on hide modal
    $scope.$on('modal.hidden', function () {
        . . .

    // Execute action on remove modal
    $scope.$on('modal.removed', function () {
        . . .
Note that we still need to use $scope for particular function.

The modal template:
        <h1 class="title">My Modal title</h1>
        <button ng-click="vm.closeModal()">Close</button>