AngularJS Scope directive
directive to create child scopes or append some data to it, useful in combination with nginclude
HTML
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script>
<div id="outer" ng:init="name = 'Gui'">
<input type="text" ng:model="name" />
The name: {{name}}
<div id="inner" ng:scope="data: name, count: 1">
inner scope: {{data}}, some additional data: {{count}}
</div>
</div>
JavaScript 1.7
class NgScopeDirective
constructor: ->
restrict : 'ACM'
scope : yes
link: (scope, element, attrs) =>
scope.$parent.$watch '{' + attrs.ngScope + '}', (data) ->
angular.extend scope, data
, yes
app = angular.module 'app', []
app.directive 'ngScope', (args...) -> new NgScopeDirective args...
angular.bootstrap document, ['app']