Thursday, February 18, 2016

What is difference between angular expression {{}} and ‘ng-bind’ and which is better?

The expression {{}} binds data to HTML same like ng-bind directive. But ng-bind is better approach than {{}}. Followings are few of the considerations.


  • Key difference is {{ }} can flash on page load while ‘ng-bind’ hides the expression until it is displayed correctly.
  • The Angular JS registers a watcher for the variable being used in ng-bind.
  • The ‘ng-bind’ stores only value of the variable in memory.

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>

    <div ng-app="" data-ng-init="var1=5;var2=7">

        <p>Result = <span data-ng-bind="var1+var2"></span></p>
        <div>Result =  {{(var1+var2)}}</div>

    </div>

</body>
</html>

Initializing multiple variables in ‘ng-init’ for AngularJS application

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>

<div ng-app="" data-ng-init="var1=5;var2=7; varStr='Hello'">
<p> <span data-ng-bind="varStr"></span></p>
<p> var1 = <span data-ng-bind="var1"></span></p>
<p>var2 = <span data-ng-bind="var2"></span></p>
<div>var1+var2 = {{(4+5)}}</div>

</div>

</body>
</html>

Tuesday, July 15, 2014

Creating nth level menu by recursion


Private Sub AppendChildToMenuStrip(ByRef DropDownItems As ToolStripItemCollection, _
                                       ByVal Tag As String, _
                                       ByVal Title As String, _
                                       ByVal ParentIDAs Integer)

            For Each Item As Object In DropDownItems

                Dim SubMenu As ToolStripMenuItem = TryCast(Item, ToolStripMenuItem)

                If SubMenu.Tag = ParentID Then

                    Dim ToolStripItem As New ToolStripMenuItem

                    ToolStripItem.Tag = Tag : ToolStripItem.Text = Title

                    SubMenu.DropDownItems.Add(ToolStripItem)

                ElseIf SubMenu.HasDropDownItems Then

                    AppendChildToMenuStrip(SubMenu.DropDownItems, Tag, Title, ParentID)

                End If

            Next

    End Sub

Using MS Script control to Evaluate Arithmetic Expressions



The MS Script Control COM component provide simple way to evaluate arithmetic expressions like below.

(2*3)/3
2+3-4
(3*4)+(4+6)/4*5

Add reference of MS Script Control COM component in the project



Following is the sample code to evaluate it.

Public Function EvaluateExpression(ByVal expression As String) As Double

        Dim ScriptControl As New MSScriptControl.ScriptControl

        ScriptControl.Language = "VBSCRIPT"
        Return Convert.ToDouble(ScriptControl.Eval(expression))
     
 End Function

Wednesday, June 5, 2013

Integrating “jqxGrid” in ASP.NET C# Application

Download Code Sample

I explored the JqxGrid on last weekend, and found it a very powerful tool for data representation on client side.

Find the attached code sample with main features filtering like Sorting, Paging and Filtering.
 Use link below to see useful demos of “jqxGrid”  and some other powerful plugins provide by jQWidgets.

http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/index.htm?(web)