<!DOCTYPE html>
<html>
  <head>
    <title>Ionic 2 QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 1. Load libraries -->
     <!-- Polyfill(s) for older browsers -->
    <script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script>
    <script src="https://unpkg.com/zone.js@0.8.12?main=browser"></script>
    <script src="https://unpkg.com/systemjs@0.19.40/dist/system.src.js"></script>

    <!-- 2. Configure SystemJS -->
    <script src="systemjs.config.js"></script>
    <link href="https://unpkg.com/ionic-angular@3.4.0/css/ionic.css" rel="stylesheet">
    <link href="style.css" rel="stylesheet">
  </head>
  <!-- 3. Display the application -->
  <body>
    <ion-app></ion-app>
    <script>
      System.import('app').catch(function(err){ console.error(err); });
    </script>
  </body>
</html>

<!-- 
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
-->
### Ionic 2 Plunk

Basic Ionic 2 plunk based on the Angular QuickStart plunk.
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true
  }
}
/**
 * PLUNKER VERSION
 * (based on systemjs.config.js in angular.io)
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    // DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
    transpiler: 'ts',
    typescriptOptions: {
      tsconfig: true
    },
    meta: {
      'typescript': {
        "exports": "ts"
      }
    },
    paths: {
      // paths serve as alias
      'npm:': 'https://unpkg.com/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      app: 'app',

      // angular bundles
      '@angular/core': 'npm:@angular/core@4.2.2/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common@4.2.2/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler@4.2.2/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser@4.2.2/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic@4.2.2/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http@4.2.2/bundles/http.umd.js',
      '@angular/forms': 'npm:@angular/forms@4.2.2/bundles/forms.umd.js',
  
      'ionic-angular': 'npm:ionic-angular@3.4.0',
      'rxjs': 'npm:rxjs@5.4.1',
      'ts': 'npm:plugin-typescript@5.2.7/lib/plugin.js',
      'typescript': 'npm:typescript@2.2.1/lib/typescript.js',

    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: './main.ts',
        defaultExtension: 'ts'
      },
      rxjs: {
        defaultExtension: 'js'
      },
      'ionic-angular': {
        main: './umd/index.js',
        defaultExtension: 'js'
      }
    }
  });
})(this);


/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/
import { Component } from '@angular/core';
import { HomePage } from './Home';

@Component({
  template: `<ion-nav [root]="rootPage"></ion-nav>`
})
export class AppComponent {

  rootPage = HomePage;

}


/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule } from 'ionic-angular';

import { AppComponent } from './app.component';
import { HomePage } from './Home';
import { ModalPage } from './Modal';

@NgModule({
  imports: [ BrowserModule, IonicModule.forRoot(AppComponent) ],
  declarations: [ AppComponent, HomePage, ModalPage ],
  entryComponents: [ HomePage, ModalPage ],
  bootstrap: [ IonicApp ]
})
export class AppModule { }


/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app.module';

const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);

/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/
<ion-header>
  <ion-navbar>
    <ion-title>{{ appName }}</ion-title>
  </ion-navbar>
</ion-header>
<ion-content padding>
    <ion-item (click)="OpenModal()">
      <ion-row>
        <ion-col col-3>
          Favorite Fruits
        </ion-col>
        <ion-col col-9 text-right>
          <ng-container *ngFor="let SelectOption of SelectOptions; let isLast=last">
             {{SelectOption.name}}{{isLast ? '' : ', '}}
          </ng-container>
          <ion-icon name="md-arrow-dropdown"></ion-icon>
        </ion-col>
      </ion-row>
    </ion-item>
</ion-content>
import { Component } from '@angular/core';
import { NavController, ModalController } from 'ionic-angular';
import { ModalPage } from './Modal';

@Component({
  selector: 'page-home',
  templateUrl: 'app/Home.html'
})
export class HomePage {
  appName = 'Ionic App';
  Options : any = [];
  SelectOptions : any = [];
  constructor(
    public navController: NavController,
    public modalCtrl : ModalController
  ) {
    this.Options = [
      { id : 1, name : 'Apple'},
      { id : 2, name : 'Blackberry'},
      { id : 3, name : 'Banana'},
      { id : 4, name : 'Cherry'},
      { id : 5, name : 'Mango'},
      { id : 6, name : 'Orange'},
      { id : 7, name : 'Pineapple'},
      { id : 8, name : 'Strawberry'},
    ];
  }
  OpenModal(){
    let profileModal = this.modalCtrl.create(ModalPage, 
      {
        title : 'Favorite Fruits',
        options : this.Options,
        selected_options : this.SelectOptions
      }
    );
    profileModal.onDidDismiss(data => {
      console.log(data);
      this.SelectOptions = data;
    });
    profileModal.present();
  }
}
import { Component } from '@angular/core';
import { NavParams, ViewController } from 'ionic-angular';

@Component({
  selector: 'modal-page',
  templateUrl: 'app/Modal.html'
})
export class ModalPage {
  
  Title : string;
  Options : any = [];
  Return : any = [];
  SelAll : boolean = false;
  SelectedOptions : any = [];
  
  constructor(
    public navParams : NavParams,
    public viewCtrl : ViewController
  ){
    this.Title = navParams.get('title');
    this.Options = navParams.get('options');
    this.SelectedOptions = navParams.get('selected_options');
    for(var i = 0; i < this.Options.length; i++){
      var c = 0
      for(var j = 0; j < this.SelectedOptions.length; j++){
        if(this.Options[i]['id'] == this.SelectedOptions[j]['id']){
          c = 1 
        }
      }
      if(c == 1){
        this.Options[i]['selected'] = true;
      } else {
        this.Options[i]['selected'] = false;
      }
    }
    if(this.Options.length == this.SelectedOptions.length){
      this.SelAll = true;
    }
  }
  
  DeSelect(t){
    if(t == false){
      this.SelAll = false;
    }
  }
  
  dismiss() {
    this.viewCtrl.dismiss(this.SelectedOptions);
  }
  
  SelectAndDismiss() {
    this.SelectedOptions = this.Options.filter(x => x.selected == true);
    this.viewCtrl.dismiss(this.SelectedOptions);
  }
  
  SelectAll(){
    if(this.SelAll == true){
      for(var i = 0; i < this.Options.length; i++){
        this.Options[i]['selected'] = true;
      }
    }
    if(this.SelAll == false){
      for(var i = 0; i < this.Options.length; i++){
        this.Options[i]['selected'] = false;
      }
    }
  }
  
}
<ion-header>
  <ion-navbar>
    <ion-title>{{ Title }}</ion-title>
  </ion-navbar>
</ion-header>
<ion-content>
  <ion-list>
    <ion-item>
      <ion-label>Select All</ion-label>
      <ion-checkbox [(ngModel)]="SelAll" (click)="SelectAll()"></ion-checkbox>
    </ion-item>
    <ion-item *ngFor="let Option of Options">
      <ion-label>{{ Option.name }}</ion-label>
      <ion-checkbox [(ngModel)]="Option.selected" (click)="DeSelect(Option.selected)"></ion-checkbox>
    </ion-item>
  </ion-list>
</ion-content>
<ion-footer no-padding>
  <ion-row>
    <ion-col no-padding>
      <button no-padding clear ion-button block color="dark" (click)="dismiss()">Cancel</button>
    </ion-col>
    <ion-col no-padding>
      <button no-padding clear ion-button block color="primary" (click)="SelectAndDismiss()">Ok</button>
    </ion-col>
  </ion-row>
</ion-footer>
ion-modal ion-backdrop {
  visibility: visible !important;
}

ion-modal .modal-wrapper {
  position: absolute;
  top: 20%;
  left: 20%;
  width: 60%;
  height: 400px;
}