Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app="App">
<head>
<script src="//code.angularjs.org/1.2.26/angular.js"></script>
  <meta charset="utf-8">
  <title>Demo</title>
</head>
<body>
  <div my-directive>
    <input type="text" value="asdasd">
  </div>
  <div my-directive>
    <input type="email" value="asdasd">
  </div>
</body>
</html>
 
angular.module('App', []).directive('myDirective', function($timeout) {
  var content={},
      idx = 0;
  return {
    scope:true,
    template: function(elm){
      elm.idx = idx;
       //Save the element in its respective index    
      content[idx++] = elm.html();
      return '<div>Template<div><pre>{{orig}}</pre></div></div>'
    },
    link: function(scope, element) {
      var idx = element.idx;
      
       scope.orig = content[idx];
      //remove key
      delete content[idx];
      if(!Object.keys(content)){ idx = 0; }
     }
  };
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers