Daily asked Questions

1.How to send objects in datatables function with Angularjs???


 ng-click="generateLink(\'' + data.influencer.id + '\' , \'' + data.influencer.username + '\' , ' + data.ppr + ')" 

2.Difference between ng-bind-html vs bind-html-compile?


bind-html-compile is not a standard Angular directive, it comes with the module https://github.com/incuna/angular-bind-html-compile and it is used to compile binded data.To make it simple, it is equivalent to write html in your source code: it will be re-evaluated and if other directives are found, they will work as expected.

ng-bind-html is a standard directive (bundled with Angular itself) and just output html strings without compiling it.

for example, if you controller has a variable with plain html, like in:

$scope.dataToDisplay = '<h1><strong>Title</strong></h1>';
Then you can go with ng-bind-html.

If you need to inject variables that contain html with other directives, such as:

$scope.dataToDisplay = '<h1 ng-show="showIfOtherVariable"><strong>Title</strong></h1>'; 

3. How do I access the $scope variable in browser's console using AngularJS?

In WebKit and Firefox, $0 is a reference to the selected DOM node in the elements tab, so by doing this you get the selected DOM node scope printed out in the console.
You can also target the scope by element ID, like so:
angular.element(document.getElementById('yourElementId')).scope()

Addons/Extensions

There are some very useful Chrome extensions that you might want to check out:
  • Batarang. This has been around for a while.
  • ng-inspector. This is the newest one, and as the name suggests, it allows you to inspect your application's scopes.

4. Angularjs-datetime-picker??

Datetime Picker

<input ng-model="date4" datetime-picker date-only /> 
 
<input ng-model="date2" datetime-picker date-format="yyyy-MM-dd" date-only /> 
 
<input ng-model="date3" datetime-picker date-format="yyyy-MM-dd HH:mm:ss" close-on-select="false" /> 
 
<input ng-model="date4" datetime-picker hour="23" minute='59'/>
 

gmtDate : "2015-01-01T00:00:00.000Z"
<input type="date" ng-model="gmtDate" size="30" />
<input ng-model="date5" datetime-picker date-format="yyyy-MM-dd HH:mm:ss" year="2014" month="12" day="31" hour="23" minute="59" />

To Get Started

For Bower users,
$ bower install angularjs-datetime-picker
Include angularjs-datetime-picker.js and angularjs-datetime-picker.css

 <link rel="stylesheet" href="angularjs-datetime-picker.css" />

 <script src="angularjs-datetime-picker.js"></script>
add it as a dependency

 var myApp = angular.module('myApp', ['angularjs-datetime-picker']);

Use it


 <input datetime-picker ng-model="model" />



5. Get selected text from a drop-down list (select box) using jQuery

$("#yourdropdownid option:selected").text();

6. How to get date format (dd-MMM-yy HH:mm) in SQL?

SELECT  FORMAT(GETDATE(),'dd-MMM-yyyy HH:mm') 


7. Get ASCI value details after input value in C#


using System;

using System.Reflection;
using System.Collections.Generic;
namespace ConsoleApplication1
{

    class Program
    {
        static void Main(string[] args)
        {
            string str = "";
            str = Console.ReadLine();
            if (str.Length > 1)
            {
                Console.WriteLine("Please enter only one character ");
                str = Console.ReadLine();

            }
            char c = Convert.ToChar(str);
            int Ascii = (int)c;

            if (Ascii >= 65 && Ascii <= 90)
            {
                Console.WriteLine("Capital Letter");

            }
            else if (Ascii >= 97 && Ascii <= 122)
            {
                Console.WriteLine("Small Letter");

            }
            else if (Ascii >= 48 && Ascii <= 57)
            {
                Console.WriteLine("Numeric Character");

            }
            else
            {
                Console.WriteLine("Special Character");

            }
            //Console.WriteLine(Ascii);
            Console.Read();

        }

    }
}

Post a Comment

0 Comments