RcBuilder@walla.com
call centre: 054-5614020

angular tracks basic example

Posted by: RcBuilder  /   Category: $http / AngularJS / autocomplete / Controllers / CSS / Data Providers / Directives / Events / Factories / HTML / JAVASCRIPT / jQuery / jquery-ui / Model / module / OOP / Services / Views   /   No Comments
27
Jan
2016

angular tracks basic example app.js var module = angular.module('my-app', ; $scope.tracks = ); } $scope.Search = function () { tracksFactory.searchForTracks($scope.searchPhrase, function (response) { $scope.tracks = response; }); } $scope.LoadAutocomplete = function () { if ($scope.searchPhrase.lengh < 3) return; tracksFactory.getNames($scope.searchPhrase, function (response) { angular.element("#searchPhrase").autocomplete({ source: response }); }); } }); module.factory('tracksFactory', function ($http) { var server = 'http://ws.audioscrobbler.com/2.0/'; var queryBase = '?method=track.search&track={0}&api_key=0604d2c5492dc743997cabe3fd636099&format=json&limit={1}'; var foreach = function (arr, callback) { for (var i = 0; i < arr.length; i++) callback.call(arr); }; return { getNames:.

Read more

OOP in javascript

Posted by: RcBuilder  /   Category: class / function / JAVASCRIPT / Object / OOP / prototype   /   No Comments
26
Jan
2016

custom Objects -------------- // Literal (a single instance) var person = { firstName: 'Roby', lastName: 'Cohen', sayYourName: function () { return this.firstName + ' ' + this.lastName; } }; console.log(person.sayYourName()); // Roby Cohen ---- // Factory (multiple instances) function PersonFactory(firstName, lastName) { return { firstName: firstName, lastName: lastName, sayYourName: function () { return this.firstName + ' ' + this.lastName; } }; } var person = PersonFactory('Roby', 'Cohen'); var person2 = PersonFactory('Avi', 'Cohen'); console.log(person.sayYourName()); // Roby Cohen console.log(person2.sayYourName()); // Avi Cohen ---- //.

Read more

javascript callback fucntion

Posted by: RcBuilder  /   Category: Array / callback / class / function / JAVASCRIPT / Object / OOP   /   No Comments
26
Jan
2016

javascript callback fucntion function foreach(arr, callback) { for (var i = 0; i < arr.length; i++) callback.call(this, arr); } var arr = ; foreach(arr, function (item) { console.log(item); }); --- function fun1(callback) { setTimeout(callback, 2000); } console.log('hey there ... '); fun1(function () { console.log('hello from callback'); }); console.log('hello again ... '); /* hey there ... hello again ... hello from callback */ --- function fun2(callback) { var user = { id: 25, Name: 'Roby Cohen', Age:.

Read more

javascript private/public

Posted by: RcBuilder  /   Category: class / function / JAVASCRIPT / Object / OOP / prototype   /   No Comments
26
Jan
2016

javascript private/public data members: private access defined using var within the object, can't be accessed from outside the object example: function Person(firstName, lastName) { var firstName = firstName; // data member var lastName = lastName; // data member ... ... } properties: public access defined using this, can be accessed from outside example: function Person(firstName, lastName) { this.firstName = firstName; // public property this.lastName = lastName; // public property ... ... } notice! we can define properties.

Read more

javascript that

Posted by: RcBuilder  /   Category: class / function / JAVASCRIPT / Object / OOP / prototype   /   No Comments
26
Jan
2016

javascript that use local variable within a custom object to save reference to the current object sometimes the 'this' variable not refer to the object contains the current function (callback calls, setTimeout etc.) the best way to handle this is by save an extra reference to the actual object (it's quite common to call it 'that') declare it in.

Read more

self-invoking functions

Posted by: RcBuilder  /   Category: class / function / JAVASCRIPT / Object / OOP   /   No Comments
26
Jan
2016

self-invoking functions declare & execute a function at the same time example: we created an anonymous function and invoked it within the declaration, the function creates a counter variable and return a reference to another function that increase this counter. the return function can access to the counter variable (as any function behaves - any function can access all of.

Read more

javascript closure

Posted by: RcBuilder  /   Category: class / function / JAVASCRIPT / Object / OOP   /   No Comments
26
Jan
2016

javascript closure the ability to create a private 'scope' for a function or an object! a closure is a persistent scope which holds on to local variables even after the code execution has moved out of that block tip: in javaScript, all functions have access to the scope "above" them. example: // note! plus = function(){ return ++counter; } var plus.

Read more

javascript overloads

Posted by: RcBuilder  /   Category: class / function / JAVASCRIPT / Object / OOP   /   No Comments
26
Jan
2016

javascript overloads there's no real overloads, we can or cannot pass parameters to the function, no exception will be thrown and any javascript parameter is an optional. use the || to set defaults whenever no param supplied (null or undefined). we can use private defaults object for a better convenience. - e.g - function myObject(param1, param2, param3, param4) { var defaults =.

Read more

javascript override

Posted by: RcBuilder  /   Category: class / function / JAVASCRIPT / Object / OOP / prototype   /   No Comments
26
Jan
2016

javascript override function Person(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; } Person.prototype.sayYourName = function () { console.log(this.firstName + ' ' + this.lastName); } // override 'toString' Person.prototype.toString = function () { return 'My Name is ' + this.firstName + ' ' + this.lastName }; var person = new Person('Roby', 'Cohen'); // override sayYourName method (change the reference) // only for the current instance person.sayYourName = function.

Read more

javascript prototype

Posted by: RcBuilder  /   Category: class / function / Object / OOP / prototype   /   No Comments
26
Jan
2016

javascript prototype * use prototype to save CPU usage and Memory consumption by defining the object functions directly on it - e.g - function Person(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; } // this 'sayYourName' method will create only once for all Person instances // instead of per each instance - less CPU usage (no need to create it per instance) //.

Read more
  • פיתוח מערכות
  • פתרונות טכנולוגים
  • קידום אתרים
  • בניית אתרים