Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.js"></script>
</head>
<body ng-app="myApp">
    <div ng-controller="MyController">
        <h2 id="appTitle">{{title}}</h2>
        <button id="newAppTitle" ng-click="setAppTitle('App 2.0')">Upgrade me!</button>
        <div my-scoped-directive msd-title="within the app {{title}}">
            <h4 id="directiveTitle">{{title}}</h4>
            <button id="newDirTitle" ng-click="setDirectiveTitle('bob')">Bob it!</button>
        </div>
    </div>
    <script type="text/javascript" src="js/app.js"></script>
</body>
</html>
 
angular.module('myApp', [])
.controller('MyController', ['$scope', function($scope){
    $scope.title = "Hello World!";
    $scope.setAppTitle = function (title) {
        $scope.title = title;
    };
}])
.directive('myScopedDirective', function() {
    return {
        scope : {
            'title' : '@msdTitle'
        },
        replace: true,
        link : function (scope, element, attrs) {
            scope.setDirectiveTitle = function (title) {
                scope.title = title;
            };
        }
    };
});
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers