AngularJS-Directives-Scope-Isolate

To demonstrate how isolate scope works in AngularJS directive

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/></div>
</div>

JavaScript

var myApp = angular.module('myApp', []);

myApp.controller('MyController', function($scope) {
    $scope.name = 'Jack';
});

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