Tutorial by Examples: di

service.ts: import { Injectable } from '@angular/core'; @Injectable() export class AppState { public mylist = []; } parent.component.ts: import {Component} from '@angular/core'; import { AppState } from './shared.service'; @Component({ selector: 'parent-example', templ...
parent.component.ts: import {Component} from '@angular/core'; @Component({ selector: 'parent-example', templateUrl: 'parent.component.html', }) export class ParentComponent { mylistFromParent = []; add() { this.mylistFromParent.push({"itemName":"Something&...
event-emitter.component.ts import { Component, OnInit, EventEmitter, Output } from '@angular/core'; @Component({ selector: 'event-emitting-child-component', template: `<div *ngFor="let item of data"> <div (click)="select(item)"> ...
shared.service.ts: import { Injectable } from '@angular/core'; import { Headers, Http } from '@angular/http'; import 'rxjs/add/operator/toPromise'; import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Rx'; import {Subject} from 'rxjs/Subject'; @Injectable(...
If you have your data with each month of data arranged in rows like so: start by creating quarterly sums in the adjacent columns, D & E in our example. Start with the third row in the new column or the first quarter you want to create, in this example we'll use March 31st (2000-03-31). Use t...
Given a directive that highlights text on mouse events import { Directive, ElementRef, HostListener, Input } from '@angular/core'; @Directive({ selector: '[appHighlight]' }) export class HighlightDirective { @Input('appHighlight') // tslint:disable-line no-input-rename highlightColor: str...
In this example, base class Singleton provides getMessage() method that returns "Hello world!" message. It's subclasses UppercaseSingleton and LowercaseSingleton override getMessage() method to provide appropriate representation of the message. //Yeah, we'll need reflection to pull this ...
This example shows how to to display specific property in dropdown but bind with the whole object. autocomplete-overview-example.html: <md-input-container> <input mdInput placeholder="State" [(ngModel)]="selection" [mdAutocomplete]="auto" [formCo...
SECTIONs in COBOL can be required or optional, depending on which DIVISION they are in. DATA DIVISION. FILE SECTION. FD SAMPLE-FILE 01 FILE-NAME PIC X(20). WORKING-STORAGE SECTION. 01 WS-STUDENT PIC A(10). 01 WS-ID PIC 9(5). LOCAL-STORAGE SECTION. 01 LS-CLASS PIC 9(3). LINKAGE SECTION. 01...
Step 1: Make a design of GridView for displaying your data (HTML Code): <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"> <Columns> <asp:TemplateField HeaderText="ID"> <ItemTemplate> ...
Design of Nested-GridView (HTML Code): <asp:GridView ID="gvParent" runat="server" AutoGenerateColumns="false" OnRowDataBound="gvParent_RowDataBound"> <Columns> <asp:TemplateField HeaderText="Parent Column"> ...
def append_to_csv(input_string): with open("fileName.csv", "a") as csv_file: csv_file.write(input_row + "\n")
PSR-1 is an accepted recommendation and outlines a basic standard recommendation for how code should be written. It outlines naming convetions for classes, methods and constants. It makes adopting PSR-0 or PSR-4 recommendations a requirement. It indicates which PHP tags to use: <?php and &lt...
datepicker-overview-example.html: <md-input-container> <input mdInput [mdDatepicker]="picker" [(ngModel)]="date" placeholder="Choose a date"> <button mdSuffix [mdDatepickerToggle]="picker"></button&gt...
This example requires MdDialogRef and MD_DIALOG_DATA. Please import them in the component module. import {MdDialog, MdDialogRef, MD_DIALOG_DATA} from '@angular/material'; input-overview-example.html: <md-input-container> <input mdInput [(ngModel)]="id" ...
Batch file does not come with a built-in method for replacing nth line of a file except replace and append(> and >>). Using for loops, we can emulate this kind of function. @echo off set file=new2.txt call :replaceLine "%file%" 3 "stringResult" type "%file...
JSON data { "name" : { "first" : "Joe", "last" : "Sixpack" }, "gender" : "MALE", "verified" : false, "userImage" : "keliuyue" } It takes two lines of Java to turn it into a User insta...
This is a compact guide about how to quickly create an R package from your code. Exhaustive documentations will be linked when available and should be read if you want a deeper knowledge of the situation. See Remarks for more resources. The directory where your code stands will be refered as ./, an...
This is an example to explain the variations of load events. onload event <body onload="someFunction()"> <img src="image1" /> <img src="image2" /> </body> <script> function someFunction() { console.log("Hi! I am l...
/*************************** log out user ***************************/ public function logout(){ //delete all session session_destroy(); $this->output->set_output(json_encode(array('status'=>true,'msg'=>'log Out successfully'))); }

Page 163 of 164