Expressions – AngularJS
AngularJS expressions contain operators,literals, and variables. AngularJS expressions can be written inside HTML while JavaScript expressions can’t be. AngularJS expressions do not support conditionals, loops, and exceptions. AngularJS expressions support filters. Expressions are written inside double curly braces. They contain variables, literals and operators. For example: {{exp}} {{23-19}} , {{11+89}}, {{stateName +’ ‘+cityName}} <!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script> <body> <div ng-app=""> <span>Expression sum: {{ 23 + 2 }}</span> </div> </body> </html> Try ng-bind: ng-bind directive can be used to bind the innerHTML to the value returned from an expression. Example without ng-bind: <div ng-app="" ng-init="a=10;b=50"> […]
Modules – AngularJS
Modules are containers for appication controller. They contain different parts of an application. <div ng-app="firstApp" ng-controller="firstCtroller"> {{ state + " " + city }} </div> <script> var app = angular.module("firstApp", []); app.controller("firstCtroller", function($scope) { $scope.state = "Hyderabad"; $scope.city = "Sikandrabad"; }); </script> Try In above example $scope. Adding Custom Directive: You can add custom directive to your application. There are certain rules to define custom directives. you nee do create module and then you can add directive to that module. <div ng-app="appOne" custom-directive></div><script> var app = angular.module("appOne", []); app.directive("customDirective", function() { return { template : "<span id='newspan' style='color:GREEN'>Hello […]
