import { Component } from '@angular/core';

@Component({
    selector: 'jb-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent {
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import { FooterComponent } from './footer/footer.component';
import { HomeComponent } from './home/home.component';
import { PersonListComponent } from './person-list/person-list.component';

import { HttpClientModule } from '@angular/common/http';

import { AjaxService } from './shared/services/ajax.service';
import { FormsModule } from "@angular/forms";
import { AppRoutingModule } from './app-routing.module';

import { RouterModule } from "@angular/router";


@NgModule({
    imports: [
        BrowserModule,
        FormsModule,
        HttpClientModule,
        RouterModule, // Need this module for the routing
        AppRoutingModule // Import app routing module
    ],
    declarations: [
        AppComponent,
        HeaderComponent,
        FooterComponent,
        HomeComponent,
        PersonListComponent
    ],
    providers: [ // Services עבור הגדרות
      AjaxService
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }

#page {
    padding: 0 0 50px 0;
    min-height: 100%;    
    box-sizing: border-box; /* Width will contain padding+border+content, Height will contain padding+border+content */
    position: relative;
    text-align: center;
    border: 2px solid black;
    background-image: linear-gradient(white, gray);
}

header {
    height: 100px;
    line-height: 100px;
    border: 0 solid black; /* TODO: check... */ 
    border-bottom-width: 2px;
}

footer {
    height: 50px;
    line-height: 50px;
    border: 0 solid black; /* TODO: check... */ 
    border-top-width: 2px;
    position: absolute;
    bottom: 0;
    width: 100%;
}
<div id="page">
    
    <header>
        <jb-header></jb-header>
    </header>

    <main>
        <!-- זהו סלקטור של מנגנון הראוטינג router-outlet -->
        <!-- יוצג במקומו רכיב מתאים לפי רשימת הנתיבים שהגדרנו -->
        <router-outlet></router-outlet>
    </main>

    <footer>
        <jb-footer></jb-footer>
    </footer>

</div>
import { NgModule } from "@angular/core";
import { Routes, RouterModule } from "@angular/router";


import { HomeComponent } from "./home/home.component";
import { PersonListComponent } from './person-list/person-list.component';

// הנתיבים השונים שקיימים באתר
const appRoutes: Routes = [
    { path: "home", component: HomeComponent },
    { path: "personInfo", component: PersonListComponent },
    { path: "", redirectTo: "/home", pathMatch: "full" }
];

// אובייקט ראוטר - יודע איך להחליף את הקומפוננטות לפי הנתיבים
const appRouter = RouterModule.forRoot(appRoutes);

@NgModule({
    imports: [appRouter]
})
export class AppRoutingModule {}




import { Injectable } from '@angular/core';

//ייבוא עבור שימוש בבקשות לשרת מרוחק
import { HttpClient } from "@angular/common/http";

import { RootObject } from '../models/personInfo'
@Injectable()
export class AjaxService{
  
  
    // זהו שירות של אנגולר המסוגל לגלוש לשרת מרוחק HttpClient
    // שירות זה הינו אסינכרוני
    constructor(private ajaxParamService: HttpClient){}

    getPerson(callback_p: (aObj: RootObject) => void): void {
      
        //פניה לשרת מרוחק ע"י שם הלינק של השרת
        this.ajaxParamService.get("https://reqres.in/api/users").subscribe(callback_p);
    }

}
import { Component, OnInit } from '@angular/core';
import { AjaxService } from './../shared/services/ajax.service';
import { RootObject } from './../shared/models/personInfo';

@Component({
    selector: 'jb-person-list',
    templateUrl: './person-list.component.html',
    styleUrls: ['./person-list.component.css']
})
export class PersonListComponent implements OnInit {


    constructor(private ajaxService: AjaxService) { }

      responseParam:RootObject=new RootObject();
      funcPram:(y:RootObject)=>void;
    
      ngOnInit(){
           this.funcPram=(x:RootObject):void => {this.responseParam=x};
            this.ajaxService.getPerson(this.funcPram);
      }

  
}

section {
    margin: 20px;
}

table {
    margin: auto;
}

td:first-child {
    text-align: left;
}

tr:nth-child(even) {
    background-color: lightblue;
}

tr:nth-child(odd) {
    background-color: lightgreen;
}

tr:first-child {
    background-color: lightgray;
}

.top-left {
    position: fixed;
    top: 120px;
    left: 20px;
    width: 150px;
}

  <h1>
   Person list:
  </h1>

<p *ngIf="!responseParam.data">before response is back from the server</p>

<div *ngIf="responseParam.data">
  <div *ngFor="let x of responseParam.data">
   <p>first_name: {{x.first_name}}</p>
   <p>last_name : {{x.last_name}}</p>
   <p>full_name : {{x.first_name + " "+ x.last_name}}</p>
 <img [src]="x.avatar"/>
  </div>
 
</div>
  
import { Component } from '@angular/core';


@Component({
    selector: 'jb-home',
    templateUrl: './home.component.html',
    styleUrls: ['./home.component.css']
})
export class HomeComponent {
  
}
h2 {
    font-size: 50px;
}

ul {
    width: 300px;
    text-align: left;
    font-size: x-large;
    padding-left: 10%;
}
<h2>Welcome to Ajax Website!</h2>
h1 {
    margin: 0;
}

nav {
    position: absolute;
    top: 0px;
    left: 20px;
}

<nav>
    <a routerLink="/home">Home</a> | 
    <a routerLink="/personInfo">Person-Info</a>
</nav>
import { Component } from "@angular/core";

@Component({
    selector: "jb-header",
    templateUrl: "./header.component.html",
    styleUrls: ["./header.component.css"]
})
export class HeaderComponent {

}
import { Component, OnInit} from '@angular/core';

@Component({
  selector: 'jb-footer',
  templateUrl: './footer.component.html',
  styleUrls: ['./footer.component.css']
})
export class FooterComponent implements  OnInit {

    ngOnInit(): void {
    }

}
<p>All Rights Reserved - 91448-2  &copy; </p>
p {
    margin: 0;
    font-weight: bold;
}
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

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




platformBrowserDynamic().bootstrapModule(AppModule);

/* Master Styles */
h1 {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 250%;
  padding-left:30px;
}

body {
  margin: 2em;
}
<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="utf-8" />
    <title>Tour of Heroes</title>
    <script>document.write('<base href="' + document.location + '" />');</script>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="icon" type="image/x-icon" href="favicon.ico" />
    <link rel="stylesheet" href="styles.css" />
    <script src="https://unpkg.com/core-js/client/shim.min.js"></script>
    <script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script>
    <script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js"></script>
    <script src="systemjs.config.js"></script>
    <script>
      System.import('main.js').catch(function(err){ console.error(err); });
    </script>
  </head>

  <body>
    <jb-root></jb-root>
  </body>

</html>
/**
 * WEB ANGULAR 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: {
      // Copy of compiler options in standard tsconfig.json
      "target": "es5",
      "module": "commonjs",
      "moduleResolution": "node",
      "sourceMap": true,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "lib": ["es2015", "dom"],
      "noImplicitAny": true,
      "suppressImplicitAnyIndexErrors": 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/animations': 'npm:@angular/animations/bundles/animations.umd.js',
      '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/common/http': 'npm:@angular/common/bundles/common-http.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
      '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
      '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',

      // other libraries
      'rxjs':                      'npm:rxjs@5.5.2',
      'rxjs/operators':            'npm:rxjs@5.5.2/operators/index.js',
      'tslib':                     'npm:tslib/tslib.js',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api@0.4/bundles/in-memory-web-api.umd.js',
      'ts':                        'npm:plugin-typescript@5.2.7/lib/plugin.js',
      'typescript':                'npm:typescript@2.4.2/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',
        meta: {
          './*.ts': {
            loader: 'systemjs-angular-loader.js'
          }
        }
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });

})(this);


var templateUrlRegex = /templateUrl\s*:(\s*['"`](.*?)['"`]\s*)/gm;
var stylesRegex = /styleUrls *:(\s*\[[^\]]*?\])/g;
var stringRegex = /(['`"])((?:[^\\]\\\1|.)*?)\1/g;

module.exports.translate = function(load){
  if (load.source.indexOf('moduleId') != -1) return load;

  var url = document.createElement('a');
  url.href = load.address;

  var basePathParts = url.pathname.split('/');

  basePathParts.pop();
  var basePath = basePathParts.join('/');

  var baseHref = document.createElement('a');
  baseHref.href = this.baseURL;
  baseHref = baseHref.pathname;

  if (!baseHref.startsWith('/base/')) { // it is not karma
    basePath = basePath.replace(baseHref, '');
  }

  load.source = load.source
    .replace(templateUrlRegex, function(match, quote, url){
      var resolvedUrl = url;

      if (url.startsWith('.')) {
        resolvedUrl = basePath + url.substr(1);
      }

      return 'templateUrl: "' + resolvedUrl + '"';
    })
    .replace(stylesRegex, function(match, relativeUrls) {
      var urls = [];

      while ((match = stringRegex.exec(relativeUrls)) !== null) {
        if (match[2].startsWith('.')) {
          urls.push('"' + basePath + match[2].substr(1) + '"');
        } else {
          urls.push('"' + match[2] + '"');
        }
      }

      return "styleUrls: [" + urls.join(', ') + "]";
    });

  return load;
};
export class PersonInfo {
        id: number;
        first_name: string;
        last_name: string;
        avatar: string;
}

export class RootObject {
        page: number;
        per_page: number;
        total: number;
        total_pages: number;
        data: PersonInfo[];
}