SHARE
TWEET

Untitled

a guest Oct 23rd, 2016 17 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {Component, OnInit} from 'angular2/core';
  2. import {CORE_DIRECTIVES, NgClass, FORM_DIRECTIVES, Control, ControlGroup, FormBuilder, Validators} from 'angular2/common';
  3.  
  4. class Resources {
  5.    ResourceDescription:string;
  6.    ResourceAddress:string;
  7. }
  8.  
  9. @Component({
  10.     selector: 'grid',
  11.     templateUrl: 'app/ts/grid.component.html',
  12.     styles: [`
  13.     body
  14.     {
  15.       font-family:Arial;
  16.       color:#3a3a3a;
  17.     }
  18.     table
  19.     {
  20.       border:none;
  21.       text-align:left;
  22.       margin-bottom:20px;
  23.     }
  24.     tr th
  25.     {
  26.           background-color: #3b97d3;
  27.         color: #fff;
  28.         padding: 5px;
  29.         border-right: solid 1px #3b97d3;
  30.         border-left: solid 1px #fff;
  31.     }
  32.     tr th:first-child
  33.     {
  34.       border-left: solid 1px #3b97d3;
  35.     }
  36.     tr td
  37.     {
  38.       padding:5px;
  39.        padding: 5px;
  40.         border-right: solid 1px #d4d4d4;
  41.     }
  42.     tr td:first-child
  43.     {
  44.       border-left: solid 1px #d4d4d4;
  45.     }
  46.     table tr:last-child td
  47.     {
  48.       border-bottom: solid 1px #d4d4d4;
  49.     }
  50.     input[type="text"]
  51.     {
  52.       height:20px;
  53.       font-size:14px;
  54.     }
  55.     a.btn
  56.     {
  57.       color:#fff;
  58.       background-color:#3b97d3;
  59.       padding:0px 10px;
  60.        height:26px;
  61.        display:inline-block;
  62.         line-height:26px;
  63.       text-decoration:none;
  64.       border-radius:3px;
  65.       -moz-border-radius:3px;
  66.       -webkit-border-radius:3px;
  67.       cursor:pointer;
  68.     }
  69.     a.btn:hover
  70.     {
  71.       background-color:#73c7ff;
  72.     }
  73.     `]
  74. })
  75.  
  76. export class GridComponent implements OnInit {
  77.     resources:Resources[] = [];
  78.    
  79.     resourcesForm: ControlGroup;
  80.     constructor(fb: FormBuilder){
  81.         this.resources = new Resources();
  82.         this.resourcesForm = fb.group({
  83.            'ResourceDescription': new Control(this.resources.ResourceDescription),
  84.            'ResourceAddress': new Control(this.resources.ResourceAddress)
  85.         });
  86.     }
  87.        
  88.     ngOnInit(){
  89.         let firstResource : Resources = {'ResourceAddress': 'http://www.example.com', 'ResourceDescription':'Great site'};
  90.         this.resources.push(firstResource);
  91.     }
  92.  
  93.     AddResource(resources:Resources) {
  94.         alert("Added " + resources.ResourceDescription + resources.ResourceAddress);
  95.         this.resources = new Resources();
  96.     }
  97.    
  98.     RemoveResource() {
  99.         alert("Resources removed!");
  100.     }
  101.    
  102.     ShowRes() {
  103.         alert('Results' + this.resources[0]);
  104.     }
  105. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top