AngulaJS

AngularJS References

Posted on

https://www.w3schools.com/angular/angular_ref_directives.asp   AngularJS Global API Converting API Description angular.lowercase() Converts a string to lowercase angular.uppercase() Converts a string to uppercase angular.copy() Creates a deep copy of an object or an array angular.forEach() Executes a function for each element in an object or array Comparing API Description angular.isArray() Returns true if the reference is an array […]

AngulaJS

AngularJS Application(Shopping List)

Posted on

<!DOCTYPE html> <html> <script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js”></script> <link rel=”stylesheet” href=”/w3css/4/w3.css”> <body> <script> var app = angular.module(“myShoppingList”, []); app.controller(“myCtrl”, function($scope) { $scope.products = [“Milk”, “Bread”, “Cheese”]; $scope.addItem = function () { $scope.errortext = “”; if (!$scope.addMe) {return;} if ($scope.products.indexOf($scope.addMe) == -1) { $scope.products.push($scope.addMe); } else { $scope.errortext = “The item is already in your shopping list.”; } } […]

AngulaJS

AngularJS Routing

Posted on

If you want to navigate to different pages in your application, but you also want the application to be a SPA (Single Page Application), with no page reloading, you can use the ngRoute module. The ngRoute module routes your application to different pages without reloading the entire application.   <!DOCTYPE html> <html> <script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js”></script> <script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-route.js”></script> <body ng-app=”myApp”> <p><a href=”#/!”>Main</a></p> <a […]

AngulaJS

AngularJS Animations

Posted on

  <!DOCTYPE html> <html> <style> div { transition: all linear 0.5s; background-color: lightblue; height: 100px; width: 100%; position: relative; top: 0; left: 0; } .ng-hide { height: 0; width: 0; background-color: transparent; top:-200px; left: 200px; } </style> <script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js”></script> <script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-animate.js”></script> <body ng-app=”myApp”> <h1>Hide the DIV: <input type=”checkbox” ng-model=”myCheck”></h1> <div ng-hide=”myCheck”></div> <script> var app = […]

AngulaJS

AngularJS Includes

Posted on

With AngularJS, you can include HTML from an external file. With AngularJS, you can include HTML content using the ng-include directive: <body ng-app=””> <div ng-include=”‘myFile.htm’”></div> </body> —————– myTable.htm: <table> <tr ng-repeat=”x in names”> <td>{{ x.Name }}</td> <td>{{ x.Country }}</td> </tr> </table> <body> <div ng-app=”myApp” ng-controller=”customersCtrl”> <div ng-include=”‘myTable.htm’”></div> </div> <script> var app = angular.module(‘myApp’, []); app.controller(‘customersCtrl’, function($scope, $http) { $http.get(“customers.php”).then(function (response) { $scope.names = response.data.records; }); }); </script> […]

AngulaJS

AngularJS Form Validation

Posted on

refer to https://www.w3schools.com The input field is required: <form name=”myForm”> <input name=”myInput” ng-model=”myInput” required> </form><p>The input’s valid state is:</p> <h1>{{myForm.myInput.$valid}}</h1> ——————— <form name=”myForm”> <input name=”myInput” ng-model=”myInput” type=”email”> </form><p>The input’s valid state is:</p> <h1>{{myForm.myInput.$valid}}</h1> ————- Form State and Input State AngularJS is constantly updating the state of both the form and the input fields. Input fields have the following states: $untouched The field has not […]

AngulaJS

AngularJS Forms

Posted on

refer to https://www.w3schools.com Data-Binding Input controls provides data-binding by using the ng-model directive. <input type=”text” ng-model=”firstname”> The application does now have a property named firstname. The ng-model directive binds the input controller to the rest of your application. The property firstname, can be referred to in a controller: Example <script> var app = angular.module(‘myApp’, []); […]

AngulaJS

AngularJS Events

Posted on

refer to https://www.w3schools.com You can add AngularJS event listeners to your HTML elements by using one or more of these directives: ng-blur ng-change ng-click ng-copy ng-cut ng-dblclick ng-focus ng-keydown ng-keypress ng-keyup ng-mousedown ng-mouseenter ng-mouseleave ng-mousemove ng-mouseover ng-mouseup ng-paste The event directives allows us to run AngularJS functions at certain user events. An AngularJS event will […]

AngulaJS

AngularJS HTML DOM

Posted on

The ng-disabled Directive   <div ng-app=”” ng-init=”mySwitch=true”> <p> <button ng-disabled=”mySwitch”>Click Me!</button> </p> <p> <input type=”checkbox” ng-model=”mySwitch”/>Button </p> <p> {{ mySwitch }} </p> </div>   Application explained: The ng-disabled directive binds the application data mySwitch to the HTML button’s disabled attribute. The ng-model directive binds the value of the HTML checkbox element to the value of mySwitch. If the value of mySwitch evaluates to true, the button will […]