Render a Directive's DOM Node Children

Description

The following code shows how to render a Directive's DOM Node Children.

Example


<!doctype html>
<html ng-app="MyApp">
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js"></script>
    <script>
var app = angular.module("MyApp", []);
<!--from   w  ww.j  a v  a2s  .co  m-->
app.directive("myWidget", function() {
  var linkFunction = function(scope, element, attributes) {
    scope.text = attributes["myWidget"];
  };

  return {
    restrict: "A",
    template: "<h1>{{text}}</h1>",
    link: linkFunction,
    scope: {}
  };
});
    </script>
    <link rel="stylesheet" href="css/bootstrap.css">
  </head>
  <body>
    <div my-widget="Hello World"></div>

  </body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities