Custom directive with namespace

Description

The following code shows how to create Custom directive with namespace.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--from w w w .  java2  s. com-->
<body ng-app="app">
   <g:text>Hello There</g:text>
  <script type='text/javascript'>
   var app = angular.module('app', []);
   app.directive('gText', function() {
        return {
            restrict: 'E',
            compile: function(tElement, attrs) {
                tElement.replaceWith('<b>' + tElement.text() + '</b>');
            }
        }
    });
</script>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities