Ionic Draft UNSORT

  1. JSON filter and sorting
  2. AngularFireDatabase
  3. Getting key  Controlling back button to specific page
  4. From project folder pass these lines
  5. Tell Git who you are
    First, you need to tell Git who you are:

    git config –global user.email “you@example.com”
    git config –global user.name “Your Name”

    Give GitHub your public keys

    Some basic Git operations
    When we worked on GitHub, the basic work cycle was fork > edit > commit > pull request > merge. The same cycle, with a few differences, is what we will work through on the commandline.

    $ git status
    # On branch master
    nothing to commit (working directory clean)

  6. Connect n merge coder from dev to tenzin
  7. git checkout dev
    git pull
    git checkout tenzin
    git merge dev
  8. Connect and merge from tenzin to dev branch
    git checkout dev
    git merge t***
    git push
    git checkout t****
  9. To connect to new branch in remote we have to follow this step
    git pull
    git checkout team
    git pull
    git checkout ngodup
    git merge team

    9.git branch commands’ various options. -a shows all local and remote branches, while -r shows only remote branches.

    git branch -a
    git branch -r
    git branch -v -r
  10. There’s also another way to do figure out what branches are on your remote by actually using the remotely related commands, git remote and git ls-remote. The former displays plenty of information about the remote in general and how it relates to your own repository, while the latter simply lists all references to branches and tags that it knows about.
    $ git remote show origin
    $ git ls-remote --heads origin

JSON FILTER N SORTING

    this.data = this.http.get('/assets/json/drills.json').map(res => {
      return res.json().drillTypes.filter(item => {
        return item.activity == 'Tactic';
      }).map(item => {
        item.serial = Number(item.serial);
        return item;
      }).sort(function (v1, v2) {
        if (v1.serial < v2.serial) {
          return -1;
        } else if (v1.serial > v2.serial) {
          return 1;
        } else {
          return 0;
        }
      });
    });
<ion-content padding>
  <ion-card *ngFor="let item of data | async">
    <ion-item (click)="goDrill(item)">
      <ion-avatar item-start>
        <img *ngIf="item.isHand" src="../../../assets/hand.png">
        <img *ngIf="item.isRacquet" src="../../../assets/racquet.png">
      </ion-avatar>
      <h4>{{activity}} {{typeName}} {{serial}}<br/>{{item.type}} {{item.serial}}</h4>
      <button ion-button color="dark" clear item-right>
        <ion-icon name="arrow-forward"></ion-icon>
      </button>
    </ion-item>

    <ion-card-content>
      <div [innerHTML]="item.description"></div>
    </ion-card-content>
  </ion-card>
</ion-content>

 

ANGULARFIREBASE DATABASE GETTING KEY 

Add the code typescript


import { AngularFireDatabase } from 'angularfire2/database';
import { DrillPage } from '../drill/drill';


export class DrillListPage {

  drills: any;
  drillPage;
  
  constructor(public navCtrl: NavController, public navParams: NavParams, private db: AngularFireDatabase) {
    this.drillPage = DrillPage;

    this.drills = this.db.list('/drills').snapshotChanges().map(changes => {
      return changes.map(drill => ({ 
        key: drill.payload.key, 
        ...drill.payload.val() 
      }));
    });
  }

Add template for accessing key 

 <ion-list>
    <button ion-item *ngFor="let drill of drills | async" (click)="itemTapped($event, drill)">
      <ion-row>
          <ion-col col-11>
            <h2>Drill key - {{drill.key}}</h2>
              <h4>{{drill.type}} {{drill.serial}}</h4>
            <span [innerHTML]="drill.description"></span>
          </ion-col>
          <ion-col col-1>
              <ion-icon name="arrow-forward"></ion-icon>
          </ion-col>
        </ion-row>
    </button>
  </ion-list>

For Angulardatabase CRUD more information – https://github.com/codediodeio/angular-firestarter/blob/master/src/app/uploads/shared/upload.service.ts


  private deleteFileData(key: string) {
    return this.db.list('/drillstype').remove(key);
  }

 

CONTROLLING BACK BUTTON FOR SPECIFIC PAGE

  ionViewDidLoad() {
    this.navBar.backButtonClick = () => {
      let pages = [{
			  page: WelcomePage
		  }];
	    this.navCtrl.setPages(pages);
	}