Posts Tagged ‘javascript’

AngularJS CheatSheet

ng-app (usually on html)

ng-controller (on the body or on the container)

‘use strict’;

scripts order: Jquery – Angular (in the head possibly) other scripts: 

var testApp = angular.module(‘myFirstAng’, []);
testApp.controller(‘myController’, function ($scope) {
$scope.Test = “hello world”;


use of $http:

myApp.controller(‘myController’, function ($scope, $http) {

dataType: ‘json’, headers: {
“Content-Type”: “application/json”
}, data: ”, method: ‘GET’,
url: ‘/api/Sdb’
}).success(function (data, status, headers, config) {
$scope.Result = data;
.error(function (data, status, headers, config) {


NG-Repeat: ng-repeat=”friend in friends”


data-ng-options=”bg.Name for bg in businessGroups”
data-ng-change=”ChangeEvent()” >
<option value=””>-Select-</option>



 <div class=“gridStyle” ng-grid=“gridOptions” style=“width: 90%; height: 90%”></div>


 $scope.gridOptions = {
                data: ‘users’, columnDefs: [
                    { field: ‘FullName’, displayName: ‘FullName’, resizable:true, width:200 },
                    { field: ‘UserName’, displayName: ‘UserName’, resizable: true },
                        field: ‘LastLogin’, displayName: ‘LastLogin’,
                        cellFilter: “date:’dd/MM/yyyy HH:mm'”
                    { field: ‘AssignedRoles’, displayName: ‘AssignedRoles’, resizable: true, cellFilter: ‘stringArrayFilter’ }]
                            function (dataReturned) {
                                $scope.users = dataReturned;

Jasmine testing:
describe("myApp", function() {
    describe("SimpleController", function() {
        var scope;
        beforeEach(inject(function($rootScope, $controller) {
            scope = $rootScope.$new();
            $controller("SimpleController", {
                $scope: scope
        it("should double the numbers", function() {
Categories: DEV, Test Tags: ,

GeoLoaction in Javascript

I found this free service for GeoLocation in Javascript…

<script language='JavaScript' src=''></script>
<script language='JavaScript'>document.write(geoip_country_code());</script>
<script language='JavaScript'>
//Redirect ALL users from ITALY on

the code is extremely easy to use, anyway I am looking forward for the proper GeoLocation API shipped with HTML5

Categories: DEV Tags: ,

JTemplates vs JQuery Template

this is one of the Jquery and UI development cool stuffs that I used in a past project…

basically you can define an html template and apply your Jquery logic so that you can separate easily the html from the JQuery logic.

latest Jquery versions officially support an other plugin
Categories: DEV Tags: ,

Json Converter

have you never need to serialize an object as Json on the page Load for further use on Javascript?!

well, I found this project very interesting…

on my projects this serializer worked perfectly, take a look at that!

Categories: DEV Tags: , ,