Angular – Numeric Control Directive

July 3, 2014

in one of LogoUi’s projects we had a requirement for  a numeric input type.My first thought was using an HTML5 input type number . Example: <input type="number" min="1" max="5"> The problem was that not all browsers has support for HTML5 input types.Check this site for more information about HTML5 forms browser support . so as a solution I decided to do 2 things: A) Use jQuery Spinner (numeric) widget which solves my cross browser compatibility issue.B) Wrap the widget as an Angular directive. Final Result: You can find my source code and more examples regarding Numeric directive in my GitHub page. Enjoy!
no comments

ng-grid – Dynamically Setting Group by One or More Fields

June 17, 2014

in one of LogoUi’s projects we had a requirement for dynamically grouping data,  trying to dynamically group data using the group property , is ignored, so after examining the ng-grid internal code, i found a solution. Setting group by one field for grouping by one field, in grid options object you need to call the groupBy function and pass the field as a string argument . Example:html: <div ng-controller="MyCtrl"> <button type="button" ng-click="changeGroupBy('name')">Group By Name</button> <button type="button" ng-click="changeGroupBy('age')">Group By Age</button> <div class="gridStyle" ng-grid="gridOptions"></div> </div> JavaScript: app.controller('MyCtrl', function($scope) { $scope.myData = [{"name": "Moroni", "age": 50}, ...
no comments

SharePoint 2013 – Add and Remove Link Items From Search Navigation Using PowerShell

May 11, 2014

Here’s a quick tip on how to add link items to SharePoint 2013 search navigation and how to remove items from search navigation. Add Items: $sites=Get-SPsite http://testsite -Limit all | Get-SPweb $node1 = new-object -TypeName "Microsoft.SharePoint.Navigation.SPNavigationNode" -ArgumentList "Link1", "http://site/sites/Search/Pages/pageA.aspx", $true $node2 = new-object -TypeName "Microsoft.SharePoint.Navigation.SPNavigationNode" -ArgumentList "Link2", "http://site/sites/Search/Pages/PageB.aspx", $true $node3 = new-object -TypeName "Microsoft.SharePoint.Navigation.SPNavigationNode" -ArgumentList "Link3", "http://site/sites/Search/Pages/PageC.aspx", $true foreach ($web in $sites) { $web.Navigation.SearchNav.AddAsFirst($node1) $web.Navigation.SearchNav.AddAsFirst($node2) $web.Navigation.SearchNav.AddAsFirst($node3) } Remove items: $navItems=@(); $sites=Get-SPsite http://testsite -Limit all | Get-SPweb foreach($web in $sites){ $navs = $web.Navigation.SearchNav foreach ($nav in $navs) { $nodeid =$web.Navigation.GetNodeById($nav.Id) $idItems+=$nodeid write-host "add id...
no comments

ng-grid – Single Row Selection for Multiple Checkbox Plugin

May 5, 2014

After working with ng-grid for awhile, I realized that single selection property is missing on configuration options when  multiple checkbox select (“select all” checkbox) is needed.I know it’s confusing, so lets take one step at a time and demonstrate what i mean, we’ll take a simple ng-grid and add the showSelectionCheckbox property. $scope.gridOptions = { data: 'myData', showSelectionCheckbox: true };   Live example: as you can see by default you have a multiple select but it’s not the desired result since we want a single row select, okay, so lets add the multiSelect property and set it to...
no comments

AngularJS – $$postDigest vs $timeout when DOM update is needed

April 8, 2014

When you need to update the DOM once after dirty checking is over or in other words, fire a callback after the current $digest cycle completes,you can use $$postDigest or $timeout.I’ll try to explain the cons and the pros of  $$postDigest and $timeout. $$postDigest  pros:          1. Fires a callback after the current $digest cycle completes.          2. Great for updating the DOM once after dirty checking is over. cons:          1. $$ means private to Angular, the interface is not stable. usage: //runs immediately after $scope.$digest$scope.$$postDigest(function(){ console.log("post Digest"); }); * it should be noted that...
2 comments

AngularJS – Why does $scope.$apply affect other scopes and how it affects performance?

March 29, 2014

as you can see from Angular’s $apply pseudo-code: function $apply(expr) { try { return $eval(expr); } catch (e) { $exceptionHandler(e); } finally { $root.$digest(); } } Internally angular does the following: $scope.$apply = $rootScope.$digest //+ some error handling and since $scope.$apply uses $rootScope, it affects all its descendants by dirty-checking EVERY data-bound objects, it’s crazy,...
one comment

AngularJS – $watch for changes in specific object property when watching an array

March 26, 2014

When deep $watch is needed on an array, but not for the entire object, you can strip off irrelevant data, this way you make the comparison much faster. Example: (solution by Karl Seamon) $scope.$watch(function($scope) { return $scope.listOfBigObjects. map(function(bigObject) { return bigObject.foo. fieldICareAbout; }); }, myHandler, true); this way you watch only what you need. Live example for watching only for "name" property: hope you’ll find this post helpful.
6 comments

Dependency Injection and Possible Future of AngularJS Presentation by Vojta Jina

January 27, 2014

A great presentation  by Vojta Jina, Senior Software Engineer in Google and a contributor to AngularJS about "Dependency Injection and Possible Future of AngularJS"  took place in ng-conf conference. A must see video and presentation about "Dependency Injection and Possible Future of AngularJS". link: Presentation document
tags: ,
no comments

Optimizing a Large AngularJS Application Presentation by Karl Seamon

A great presentation  by Karl Seamon, Senior Software Engineer in Google and a contributor to AngularJS about "Optimizing a Large Angular Application" took place in ng-conf conference. A must see video and presentation about optimizing a Large AngularJS Application. The covered topics are: A) The Problems B) Basics and Best Practices C) Diagnosing performance problems D) Improving performance within AngularJS link: Presentation Document
no comments

AngularJS – HTML5 Canvas Drag and Drop Directive Using KineticJS

January 7, 2014

Recently for one of my projects I needed to add drag and drop (DnD) functionality. After examining the native HTML5 DnD I come to conclusion that the awesome HTML5 feature still suffers from cross browser computability issues, second of all the lack of mobile touch support really pissed me off. On the other hand, Canvas has no cross browser computability issues and has a great touch support. To make a long story short, I implemented Canvas DnD functionality in AngularJS directive. We use KineticJS -an HTML5 Canvas JavaScript framework that enables high performance animations, transitions, node nesting, layering, filtering, caching, event handling...
no comments