AngularJS-Directive-Scope-Isolated-Oneway

o demonstrate how isolate scope with oneway syntax works

by madhanganesh

HTML

<div ng-app='myApp' ng-controller="MyController">
  <h1>HTML View - scope</h1>
  <strong>Name: </strong> <input ng-model="name"/>
  <hr/>
  <h2>Directive</h2>
  <div upper-case name={{name}} /></div>
</div>

JavaScript

var myApp = angular.module('myApp', []);
 
myApp.controller('MyController', function($scope) {
  $scope.name = 'Jack';
 });

myApp.directive('upperCase', function() {
  return {
    scope: {
      name: '@name'
    },
    template: 'Name: <input ng-model="name"></input>'
  }
});