‏הצגת רשומות עם תוויות javascript. הצג את כל הרשומות
‏הצגת רשומות עם תוויות javascript. הצג את כל הרשומות

יום ראשון, 9 ביוני 2013

simple angular js

Very simple angular page
The HTML view

  1: <!doctype html>
  2: <html ng-app>
  3:   <head>
  4:     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script>
  5:     <script src="operators.js"></script>
  6:     <link rel="stylesheet" href="operators.css">
  7:   </head>
  8:   <body>
  9:     <h2>Operators</h2>     
 10:     <div ng-controller="OperatorsContoller">     
 11:       <ul >
 12:         <li ng-repeat="operator in operators">         
 13:           <span>{{operator.name}}</span>           
 14:         </li>
 15:       </ul>
 16:     </div>
 17:   </body>
 18: </html>

The  controller


  1: function OperatorsContoller($scope) {
  2:     $scope.operators = [
  3:       { "name": "Zvika" },
  4:       { "name": "Gal" }];
  5: }
The Result
Capture23

יום ראשון, 12 במאי 2013

using switch in javascript

The following script demonstrate the use of switch statement in javascript
<!DOCTYPE html>
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
   <body>
       <p>Click the button to display the current Date.</p
       <button id="GetCurrentDateBtn">Get current Date</button>
        <p id="CurrentDate"></p>
</body>

</html>
<script src="Scripts/jquery-1.7.1.js"></script>
<script>

    $(document).ready(function () {
        $("#GetCurrentDateBtn").on("click", function ()
        {
            HandleTheCurrentDateDispaying();
        });     
    });

    function HandleTheCurrentDateDispaying()
    {
        var theDayDiscreption ;
        var theDay = new Date().getDay();
        switch (theDay) {
            case 0:
                theDayDiscreption = "Sun";
                break;
            case 1:
                theDayDiscreption = "Mon";
                break;
            case 2:
                theDayDiscreption = "tue";
                break;         
            default:
                theDayDiscreption = "Sat";
        }

        $("#CurrentDate").text("<i>" + theDayDiscreption + "</i>");
    }
       
</script>