if (window.attachEvent) //IE { window.attachEvent("onload", initApp); } if (window.addEventListener)//Firefox { window.addEventListener("load", initApp,false); } function initGame() { var myControl = new Control(); }
public static Control narrowToControl(JSObject object) { return new Control(object); }
constructor() { this.ctrl = new Control(); this.ctrl.valueChanges.delay(3000).subscribe((value) => { this.func(); });
public static Control narrowToControl(JSObject object){ return new Control(object); }
var oControl = new Control({ click: this.performAction.bind(this) });
Button myButton = new Control(); // Not actually a button!
@Component({ (...) template: ` <input type="text" value="{{userInput}}" class="form-control" [ngFormControl]="ctrl"> ` }) export class SomeComponent { constructor() { this.ctrl = new Control(); this.ctrl.valueChanges .filter((value) => { return (value.length > 3); }) .subscribe((value) => { // do something }); } }
function Control(value){ Control.instances = Control.instances || []; Control.instances.push(this); var self=this; self.param1=value; self.param2=value.text; } // In case you are worried about garbage collection Control.prototype.destroy = function() { var index = Control.instances.indexOf(this); Control.instances.splice(index, 1); } // Usage: var x = new Control(); var y = new Control(); // do stuff with x and y console.log('There are ' + Control.instances.length + ' instances of Control'); // all done with x and y x.destroy(); x = null; y.destroy(); y = null; // no more references to the two instances, they can be garbage collected
@Component({ (...) template: ` <input [ngFormControl]="ctrl"/> ` }) export class MyComponent { constructor() { this.ctrl = new Control(); this.ctrl.valueChanges .debounceTime(500) .distinctUntilChanged() .switchMap((vallue: string) => { // Get data according to the filled value return this.service.getData(entry); }) .subscribe(data => { // Update the linked list this.list = data; }); } }
private static Control MY_CONTROL = new Control() { @Override public long getTimeToLive(String baseName, Locale locale) { return MY_TTL; //make shure, that changes are checked periodically } }; public static String getParamter(String name) { ResourceBundle config = ResourceBundle.getBundle("config", MY_CONTROL); return config.getString(name); }
function Control(element_finder) {
public static string ResolveUrl(this HtmlHelper html, string virtualUrl) { Control con = new Control(); var RelativeUrl = con.ResolveUrl(virtualUrl); if (!virtualUrl.StartsWith("~/")) return RelativeUrl; virtualUrl = virtualUrl.Remove(0, 2); string applicationPath = html.ViewContext.HttpContext.Request.ApplicationPath; if (string.IsNullOrEmpty(applicationPath) || !applicationPath.EndsWith("/")) { applicationPath = applicationPath + "/"; } return applicationPath + virtualUrl; } }