directives – OnlineWebTutorial.Com

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 […]


Directives – AngularJS

Using Directives you can extend HTML attributes. In AngularJS you can define your own directives while it has its own set of directives. In angularJS, directives start with ng- prefix like ng-app, ng-init, ng-model etc. <div ng-app="" ng-init="a=10;b=50"> <p>Result: {{ a * b }}</p> </div> Try   Using ng-bind: <div ng-app="" ng-init="a=10;b=50"> <p ng-bind="a * b"></p> </div> Try   Data Binding in AngularJS: Using ng-model directive it binds AngularJS expressions with AngularJS data. Repeating nodes: ng-repeat directive is used to repeat HTML elements in AngularJS. <span ng-app=”” ng-init=”states=[‘UP’,’MP’,’HYD’]”> <ul> <li ng-repeat=”a in states”> {{ a }} </li> </ul> </span> Try […]


Facebook
Google+
Twitter
Visit Us
PINTEREST
LinkedIn