Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app="stackApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body ng-controller="StackController as form">
  <field type="text" ng-model="field1"></field>
  <field type="number" ng-model="field2"></field>
</body>
</html>
 
var StackController = function() {
  this.field1 = 'value';
  this.field2 = 45;
};
angular.module('stackApp', [])
  .controller('StackController', StackController)
    .directive('field', function($compile){
        return {
            restrict: 'E',
            template: function(tElement, tAttributes) {
                var template = '<input type="'+tAttributes.type+'" ng-model="form.'+tAttributes.ngModel+'" /> {{form.'+tAttributes.ngModel+'}}';
              
              return template;
            }
        };
});
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers