Tutorial by Examples

Theme: A theme is required for material components to work properly within the application. Angular Material 2 provides four prebuilt themes: deeppurple-amber indigo-pink pink-bluegrey purple-green If you are using Angular CLI, you can import one of the prebuilt themes in style.css. @i...
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 pipe that reverse a string import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'reverse' }) export class ReversePipe implements PipeTransform { transform(value: string): string { return value.split('').reverse().join(''); } } It can be tested configuring th...
To create a component we add @Component decorator in a class passing some parameters: providers: Resources that will be injected into the component constructor selector: The query selector that will find the element in the HTML and replace by the component styles: Inline styles. NOTE: DO NOT us...
Templates are HTML files that may contain logic. You can specify a template in two ways: Passing template as a file path @Component({ templateUrl: 'hero.component.html', }) Passing a template as an inline code @Component({ template: `<div>My template here</div>`, }) Tem...
hero.component.html <form (ngSubmit)="submit($event)" [formGroup]="form" novalidate> <input type="text" formControlName="name" /> <button type="submit">Show hero name</button> </form> hero.component.ts import...
Components will render in their respective selector, so you can use that to nest components. If you have a component that shows a message: import { Component, Input } from '@angular/core'; @Component({ selector: 'app-required', template: `{{name}} is required.` }) export class RequiredC...
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...
Let's assume we have a Dogs application, then our model will be a Dog class. DatabaseReference reference = FirebaseDatabase.getInstance().getReference().child("dogs"); This is how to send a Dog to the database, a new unique dog and set the dog with the key. String key = reference.push...
A module is a class with the @NgModule decorator. To create a module we add @NgModule passing some parameters: bootstrap: The component that will be the root of your application. This configuration is only present on your root module declarations: Resources the module declares. When you add a ne...
Modules can be nested by using the imports parameter of @NgModule decorator. We can create a core.module in our application that will contain generic things, like a ReservePipe (a pipe that reverse a string) and bundle those in this module: import { CommonModule } from '@angular/common'; import {...
Given a service that can login a user: import 'rxjs/add/operator/toPromise'; import { Http } from '@angular/http'; import { Injectable } from '@angular/core'; interface LoginCredentials { password: string; user: string; } @Injectable() export class AuthService { constructor(pri...
Using the dynamic variable %Random%, we can get a random integer from 0 to 32767. For example: echo %random% This obviously, returns an integer from 0 to 32767. But sometimes we want it to be in a specific range, say from 1 to 100. Generating Random Numbers Within Specific Range The basic me...
Unfortunately, batch does not have a built-in method to generate alphabets, but using %random% and for loop, we can 'generate' alphabets. This is a simple idea of how this works. set /a result=(%random%*26/32768)+1 for /f "tokens=%result%" %%I in ("A B C D E F G H I J K L M N O P...
The model view controller is a very common design pattern that has been around for quite some time. This pattern focuses on reducing spaghetti code by separating classes into functional parts. Recently I have been experimenting with this design pattern in Unity and would like to lay out a basic exam...
In Unix/Posix systems: >$ echo "Hello World!" This simple command will print Hello World on the terminal.
Here is how to create your own singleton class for toast messages, If your application need to show success, warning and the danger messages for different use cases you can use this class after you have modified it to your own specifications. public class ToastGenerate { private stati...
The MyFrame class the extends JFrame and also contains the main method import javax.swing.JFrame; public class MyFrame extends JFrame{ //main method called on startup public static void main(String[] args) throws InterruptedException { //creates a frame window ...
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 ...
The below example uses Android.Runtime.InputStreamInvoker and Android.Runtime.OutputStreamInvoker types obtain Java.IO.InputStream and Java.IO.OutputStream. Once we have a Java.IO.InputStream instance, we can use its .Available() method to get the number of available response bytes which we can use...

Page 1323 of 1336