Full Trust European Hosting

BLOG about Full Trust Hosting and Its Technology - Dedicated to European Windows Hosting Customer

Angular.js Hosting Italy - HostForLIFE.eu :: AngularJS Directive for Email

clock April 7, 2015 11:52 by author Peter

In this article, I will explain you about AngularJS directive for email. At the point when executing a Single Page Application utilizing WebAPI and AngularJS, you experience numerous uses of filters and directives to meet requirements specified by clients. The accompanying code tokenizes the info and presentations it in a different square inside a particular placeholder, in any case it checks the data for a substantial email address first and then the information token is not rehashed inside the same placeholder. And now, write the following code:

<body ng-app="tokenizer"> 
    <div ng-controller="tokenizerController"> 
        <tag-input taglist='email' placeholder="Emails"></tag-input>   
    </div> 
</body> 


    var sample = angular.module('tokenizer', ['ngRoute']);              
    sample.controller('tokenizerController', function ($scope) {               
      }); 
             sample.directive('tagInput', function ()
    { 
           return
            { 
               restrict: 'E',                 
               scope:
                { 
                  inputTags: '=taglist', 
                   autocomplete: '=autocomplete' 
                  }, 
                   link: function ($scope, element, attrs)
                  { 
                   $scope.defaultWidth = 200; 
                   $scope.tagText = ''; 
                   $scope.placeholder = attrs.placeholder; 
                   $scope.tagArray = function ()
                      { 
                       if ($scope.inputTags === #ff0000)
                       { 
                           return []; 
                       } 
                       return $scope.inputTags.split(',').filter(function (tag)
                       { 
                           return tag !== ""; 
                       }); 
                   }; 
                   $scope.addTag = function ()
                       { 
                       var EMAIL_REGEXP = /^[_a-z0-9]+(\.[_a-z0-9]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/; 
                       var tagArray; 
                       if ($scope.tagText.length === 0) { 
                           return; 
                        } 
                       if (!EMAIL_REGEXP.test($scope.tagText))
                       { 
                           return $scope.tagText = ""; 
                       } 
                       tagArray = $scope.tagArray(); 
                       if (!(tagArray.indexOf($scope.tagText) >= 0))
                       { 
                           tagArray.push($scope.tagText); 
                           $scope.inputTags = tagArray.join(','); 
                       } 
                       return $scope.tagText = ""; 
                   }; 
                   $scope.deleteTag = function (key)
                       { 
                       var tagArray; 
                       tagArray = $scope.tagArray(); 
                       if (tagArray.length > 0 && $scope.tagText.length === 0 && key === #ff0000)
                      { 
                           tagArray.pop(); 
                       }
                       else
                         { 
                           if (key !== undefined)
                           { 
                               tagArray.splice(key, 1); 
                           } 
                       } 
                       return $scope.inputTags = tagArray.join(','); 
                   }; 
                   $scope.$watch('tagText', function (newVal, oldVal)
                    { 
                       var tempEl; 
                       if (!(newVal === oldVal && newVal === undefined))
                          { 
                           tempEl = $("<span>" + newVal + "</span>").appendTo("body"); 
                           $scope.inputWidth = tempEl.width() + 5; 
                           if ($scope.inputWidth < $scope.defaultWidth)
                           { 
                               $scope.inputWidth = $scope.defaultWidth; 
                           } 
                           return tempEl.remove(); 
                       } 
                   }); 
                   element.bind("keydown", function (e) { 
                       var key; 
                       key = e.which; 
                       if (key === 9 || key === 13) { 
                           e.preventDefault(); 
                       } 
                       if (key === 8) { 
                           return $scope.$apply('deleteTag()'); 
                       } 
                   }); 
                   return element.bind("keyup", function (e) { 
                       var key; 
                       key = e.which; 
                       if (key === 9 || key === 13 || key === 188) { 
                           e.preventDefault(); 
                           return $scope.$apply('addTag()'); 
                       } 
                   }); 
               }, 
               template: "<div class='tag-input-ctn'><div class='input-tag' data-ng-repeat=\"tag in tagArray()\">{{tag}}<div class='delete-tag' data-ng-click='deleteTag($index)'>×</div></div><input type='text' data-ng-style='{width: inputWidth}' data-ng-model='tagText' placeholder='{{placeholder}}'/></div>" 
           }; 
       });  

HostForLIFE.eu AngularJS Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



Angular.js Hosting UK - HostForLIFE.eu :: Double Click Event in AngularJS

clock March 30, 2015 09:06 by author Peter

This article explains double-click events in AngularJS. we've already explained mouse events exploitation AngularJS in my previous article Mouse Events exploitation AngularJS. currently during this article i'm explaining the ng-dblclick directive of AngularJS.

ng-dblclick
This allows you to specify custom behaviour on a double-click event of the mouse on the web page. we will use it (ng-dblclick) as an attribute of the HTML component like:
<ANY_HTML_ELEMENT  ng-dblclick="{expression}">  
  ...  
</ANY_HTML_ELEMENT>

Use the subsequent procedure to make a sample of a double-click event using AngularJS. First of all, you would like to add an external Angular.js file to your application, for this you'll be able to visit the AngularJS official website or transfer my source code then fetch it or click on this link and download it: ANGULARJS. once downloading the external file you would like to add this file to the head section of your application. Now, I'll show you the way to use the ng-dblclick directive. I am making a TextBox and button and binding the TextBox using the ng-model directive and therefore the button using the ng-dblclick directive. The code is as follows:
<body>
    Name:
    <input ng-model="name" type="text" />
    <button ng-dblclick="Msg='Hello '+name">
        Double Click
    </button>
    </br>
    <h3>
        {{Msg}}</h3>
</body>


Here the TextBox ties with ng-demonstrate, The catch is bound with ng-dblclick and inside the ng-dblclick I have composed 'Hello  '+name. Where Hello is a string and name is a variable that contains the value of the input TextBox. This button will work when you double-click on it.

And here is the code that I used:
<!doctype html>
<html ng-app>
<head>
    <script src="angular.min.js"></script>
</head>
<body>
    Name:
    <input ng-model="name" type="text" />
    <button ng-dblclick="Msg='Hello '+name">
        Double Click
    </button>
    </br>
    <h3>
        {{Msg}}</h3>
</body>
</html>

Here is the Output, when Page loads:

HostForLIFE.eu AngularJS Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



AngularJS Hosting UK - HostForLIFE.eu :: The .directive and .filter Service in AngularJS

clock March 10, 2015 07:03 by author Peter

This article clarifies the .directive and .filter service in AngularJS. Precise gives numerous sorts of administrations, two of them are directive and filter. In this article I will demonstrate to you an application in which both of the administrations are utilized.

Most importantly you have to add an outside Angular.js record to your application, as it were "angular.min.js".  For this you can go to the AngularJS official site.In the wake of downloading the external file you have to add this document to the Head segment of your application.
<head runat="server">
    <title></title>
    <script src="angular.min.js"></script>
</head>

After add the External JS file, the first thing you should do is to add ng-app in the <HTML> Tag otherwise your application will not run.
<html ng-app xmlns="http://www.w3.org/1999/xhtml">


On the JavaScript function, write the following code in the head section:
    <script>
        var x = angular.module('x', []); 
        function ctrl($scope) {
            $scope.name = 'testing';
       }
        angular.module('mod', [])
          .filter('ifarray', function () {
              return function (input) {
                  return $.isArray(input) ? input : [];
              }
         })
          .directive('list', function ($compile) {
              return {
                  restrict: 'E',
                  terminal: true,
                  scope: { val: 'evaluate' },
                  link: function (scope, element, attrs) {
                      if (angular.isArray(scope.val)) {
                          element.append('<div>+ <div ng-repeat="v in val"><list val="v"></list></div></div>');
                      } else {
                          element.append('  - {{val}}');
                      }
                     $compile(element.contents())(scope.$new());
                  }
              }
         });
        angular.module('x', ['mod']);
     </script>

Here I made a module whose name is "x", this module will be brought in the g-app directive. After this I made a functionwhose name is "ctrl", in this function one introductory value is passed in the variable "name".  After making the function, I utilized the filter and directive administrations, in the directive administration I passed limit as "E". In this directive service I connected an "if" circle that will check whether the Array is utilized, if the array is utilized then it will attach a few controls to the component. I utilized a <list> control that is not a control, it’s an customized control that is not accessible in HTML. Now our work on JavaScript is completed and we can move to the design part of our application. Write this code in the body section:
<body>
    <form ng-app="x" id="form1" runat="server">
    <pre>
        <list val="['item1','item2',['item3','item4']]">
        </list>
    </pre>
    </form>
</body>

Here I bound the module name with the form using the ng-app directive. I utilized the custom component that was pronounced in the second step, in this <list> I bound some beginning values that will be seen in the yield window. Now, our application is made and is prepared for execution.

Output
When you running the application you will get a output like this:

You can see that the <list> is showing the output but it was not any official element.
The complete code of this application is as follows:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="JavaScript1.js"></script>
    <script>
        var x = angular.module('x', []);
        function ctrl($scope) {
            $scope.name = 'testing';
        }
        angular.module('mod', [])
          .filter('ifarray', function () {

              return function (input) {
                  return $.isArray(input) ? input : [];
             }
          })
          .directive('list', function ($compile) {
              return {
                  restrict: 'E',
                  terminal: true,
                  scope: { val: 'evaluate' },
                  link: function (scope, element, attrs) {
                      if (angular.isArray(scope.val)) {
                          element.append('<div>+ <div ng-repeat="v in val"><list val="v"></list></div></div>');
                      } else {
                          element.append('  - {{val}}');
                      }
                      $compile(element.contents())(scope.$new());
                  }
              }
          });
        angular.module('x', ['mod']);
    </script>
</head>
<body>
    <form ng-app="x" id="form1" runat="server">
    <pre>
        <list val="['item1','item2',['item3','item4']]">
        </list>
   </pre>
    </form>
</body>
</html>

HostForLIFE.eu AngularJS Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



AngularJS Hosting - HostForLIFE.eu :: How to Create Alert Box with AngularJS?

clock February 10, 2015 17:14 by author Peter

In this short tutorial, I will show you how to create an alert box using AngularJS. There is the difference between JavaScript and AngularJS. In AngularJS "$window" is need to referring to global Window Objects. If you want to show the alert in Angular then you need to pass it as $window.alert. First step is you need to add an external Angular.js file to your app. You need to visit the AngularJS website. After downloading the external file, you should add the following code to the Head section of your application.

 

 <head runat="server">
    <script src="angular.min.js"></script>
    <title></title>
</head>

Next step, I will create a function and write this function in the head section of your apps:
<script>
        function greet($window, $scope) {
            $scope.hello = function () {
                $window.alert('Hi!! ' + $scope.name);
            }
        }
</script>

We created a function named "greet", in $scope function and $window are passed as objects as a result of scope is used to pass a value to the controller and as you recognize we are going to show an alert window. that's why $window is used.

An alert is used but have $window before it, during this alert the message "Hi!!" are displayed at the side of some value that will be passed through a TextBox. This will be done using the $scope.name. Now you'll be thinking that I have neither declared name anyplace nor provided an initial value to the scope, you'll pass the initial value before this hello function however that may solely help to point out some text by default and nothing much more than that.

Now write this code in the body section:
  <body>
    <div ng-controller="greet">
      Name: <input ng-model="name" type="text"/>
      <button ng-click="greet()">Greet</button>
    </div>
  </body>

Here first I have applied a controller to a div, then an input tag is used in which "name" is applied through the ng-model, thus no matter is entered into the TextBox are shown within the alert box on the click of a button. The button click is sure to greet using the ng-click(). currently our work on this application is completed and it's complete code is as follows:
<head runat="server">
    <script src="angular.min.js"></script>
    <title></title>
    <script>
        function greet($window, $scope) {
            $scope.hello = function () {
                $window.alert('Hi!! ' + $scope.name);
            }
        }
    </script>
</head>
    <body>
    <div ng-controller="greet">
      Name: <input ng-model="name" type="text"/>
      <button ng-click="greet()">Greet</button>
    </div>
  </body>
</html>

On running the application you will see a TextBox and a Button.

If now I click on the Button then an Alert message will be shown but in the alert box "Hello Undefined" will be shown because nothing is provided through the TextBox and no initial value was passed through the $scope.

HostForLIFE.eu AngularJS Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in