function getCookieValue(a) {
var b = document.cookie.match('(^|;)\\s*' + a + '\\s*=\\s*([^;]+)');
return b ? b.pop() : '';
}https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#JavaScript_access_using_Document.cookie
| import React from 'react'; | |
| const ProductDetail = ({ product }) => ( | |
| <React.Fragment> | |
| <h2>{product.title}</h2> | |
| <div>{product.description}</div> | |
| </React.Fragment>); | |
| class Fetch extends React.Component { |
| //Component.html | |
| <p-column *ngFor="let col of cols; let i = index" [field]="col.field" [header]="col.header"> | |
| <ng-template pTemplate="body" let-car="rowData"> | |
| <span *ngIf="car.editable" [attr.data-index]="i"> | |
| <input type="text" (keyup)="populate($event, i)" > | |
| </span> | |
| <span *ngIf="!car.editable">{{car[col.field]}}</span> | |
| </ng-template> | |
| </p-column> | |
| import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | |
| import { FormsModule } from '@angular/forms'; | |
| import { SaveContactComponent } from './save-contact.component'; | |
| import { Contact } from '../models/contact'; | |
| import { DebugElement } from '@angular/core'; | |
| import { By } from '@angular/platform-browser'; | |
| describe('SaveContactComponent', () => { | |
| let component: SaveContactComponent; | |
| let fixture: ComponentFixture<SaveContactComponent>; |
| import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | |
| import { AddressBookComponent } from './address-book.component'; | |
| import { NO_ERRORS_SCHEMA } from '@angular/core'; | |
| import { AddressBookDataService } from '../services/address-book-data.service'; | |
| describe('AddressBookComponent', () => { | |
| let component: AddressBookComponent; | |
| let fixture: ComponentFixture<AddressBookComponent>; | |
| let addressBookDataServiceStub: any; |
| import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | |
| import { ContactComponent } from './contact.component'; | |
| import { Contact } from '../models/contact'; | |
| import { DebugElement } from '@angular/core'; | |
| import { By } from '@angular/platform-browser'; | |
| describe('ContactComponent', () => { | |
| let component: ContactComponent; | |
| let fixture: ComponentFixture<ContactComponent>; |
| import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | |
| import { HeaderComponent } from './header.component'; | |
| import { DebugElement } from '@angular/core'; | |
| import { By } from '@angular/platform-browser'; | |
| describe('HeaderComponent', () => { | |
| let component: HeaderComponent; | |
| let fixture: ComponentFixture<HeaderComponent>; |
| import { TestBed, inject } from '@angular/core/testing'; | |
| import { AddressBookDataService } from './address-book-data.service'; | |
| import { Contact } from '../models/contact'; | |
| describe('AddressBookDataService', () => { | |
| beforeEach(() => { | |
| TestBed.configureTestingModule({ | |
| providers: [AddressBookDataService] | |
| }); |
| import { Contact } from './contact'; | |
| describe('Contact', () => { | |
| it('should create an instance', () => { | |
| expect(new Contact()).toBeTruthy(); | |
| }); | |
| it('should accept values from constructor', () => { | |
| let contact = new Contact({ | |
| firstName: 'John', |
| var count = 5; | |
| function test () { | |
| console.log(this.count === 5); | |
| } | |
| test() // Prints true as “count” variable declaration happened in global execution context so count will become part of global object. |