Tutorial by Examples: v

The view-model is the "VM" in MVVM. This is a class that acts as a go-between, exposes the model(s) to the user interface (view), and handling requests from the view, such as commands raised by button clicks. Here is a basic view-model: public class CustomerEditViewModel { /// <s...
The View is the "V" in MVVM. This is your user interface. You can use the Visual Studio drag-and-drop designer, but most developers eventually end up coding the raw XAML - an experience similar to writing HTML. Here is the XAML of a simple view to allow editing of a Customer model. Rather...
From ES5.1 onwards, you can use the native method Array.prototype.filter to loop through an array and leave only entries that pass a given callback function. In the following example, our callback checks if the given value occurs in the array. If it does, it is a duplicate and will not be copied to...
var arr = [1, 2, 3, 4]; Method 1 Creates a new array and overwrites the existing array reference with a new one. arr = []; Care must be taken as this does not remove any items from the original array. The array may have been closed over when passed to a function. The array will remain in mem...
This query will return all COLUMNS and their associated TABLES for a given column name. It is designed to show you what tables (unknown) contain a specified column (known) SELECT c.name AS ColName, t.name AS TableName FROM sys.columns c JOIN sys.tables t ON c.object_id = t.o...
Sometimes, it's not possible to list the number of parameters a function could need. Consider a sum function: func sum(_ a: Int, _ b: Int) -> Int { return a + b } This works fine for finding the sum of two numbers, but for finding the sum of three we'd have to write another function: f...
If you ever wanted to determine the html content to be printed on a page during run time then, rails has a very good solution for that. It has something called the content_for which allows us to pass a block to a rails view. Please check the below example, Declare content_for <div> <%=...
/** * The buildscript {} block is where you configure the repositories and * dependencies for Gradle itself--meaning, you should not include dependencies * for your modules here. For example, this block includes the Android plugin for * Gradle as a dependency because it provides the addition...
Dim extensions As New Dictionary(Of String, String) _ from { { "txt", "notepad" }, { "bmp", "paint" }, { "doc", "winword" } } This creates a dictionary and immediately fills it with three KeyValuePairs. You can also add new val...
people := map[string]int{ "john": 30, "jane": 29, "mark": 11, } for _, value := range people { fmt.Println("Age:", value) } Note that when iterating over a map with a range loop, the iteration order is not specified and is not guaranteed to...
Transforms hold the majority of data about an object in unity, including it's parent(s), child(s), position, rotation, and scale. It also has functions to modify each of these properties. Every GameObject has a Transform. Translating (moving) an object // Move an object 10 units in the positive ...
let minimumVersionString = "3.1.3" let versionComparison = UIDevice.current.systemVersion.compare(minimumVersionString, options: .numeric) switch versionComparison { case .orderedSame, .orderedDescending: //current version is >= (3.1.3) break case .orderedA...
Int("123") // Returns 123 of Int type Int("abcd") // Returns nil Int("10") // Returns 10 of Int type Int("10", radix: 2) // Returns 2 of Int type Double("1.5") // Returns 1.5 of Double type Double("abcd") // Returns nil Note that do...
To show a message box when the form has been shown: Public Class Form1 Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown MessageBox.Show("Hello, World!") End Sub End Class To show a message box before the form has been shown: Public Cla...
When dividing two numbers pay attention to the type you want in return. Note that dividing two integers will invoke the integer division. If your goal is to run the float division, at least one of the parameters should be of float type. Integer division: 3 / 2 # => 1 Float division 3 / 3.0 ...
A module, that is using Ports should have port keyword in it's module definition. port module Main exposing (..) It is impossible to use ports with Html.App.beginnerProgram, since it does not allow using Subscriptions or Commands. Ports are integrated in to update loop of Html.App.program or Ht...
<div [class.active]="isActive"></div> <span [style.color]="'red'"></span> <p [attr.data-note]="'This is value for data-note attribute'">A lot of text here</p>
import { Component } from '@angular/core'; @Component({ selector: 'my-app', template: ` <h1>Angular 2 App</h1> <p>Component is directive with template</p> ` }) export class AppComponent { }
<div *ngFor="let item of items">{{ item.description }}</div> <span *ngIf="isVisible"></span>
import {Directive, ElementRef, Renderer} from '@angular/core'; @Directive({ selector: '[green]', }) class GreenDirective { constructor(private _elementRef: ElementRef, private _renderer: Renderer) { _renderer.setElementStyle(_elementRef.nativeElement, 'color', 'gree...

Page 55 of 296