AngularJS Isolated Scope Experiment
This is a fiddle designed to illustrate isolated scope using the updated and simpler syntax.
This is a take on John Lindquist's fiddle which looked like this:
http://jsfiddle.net/simpulton/RUbSv/
HTML
<script src="http://code.angularjs.org/1.0.1/angular-1.0.1.js"></script>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<div ng-controller="MyCtrl">
<div>
{{model | json}}
</div>
<div>
{{items | json}}
</div>
<div>
{{equal}}
</div>
<div>
<div select-block items="items" model="model"></div>
</div>
</div>
JavaScript
var myModule = angular.module('myModule', [])
.controller('MyCtrl', ['$scope', function ($scope) {
$scope.model = { name: ' hans', game: 'wow' };
$scope.items = [{ name: ' jens', game: 'wow' }, { name: ' hans', game: 'wow' }];
$scope.equal = angular.equals($scope.items[1], $scope.model);
}]);
myModule.directive('selectBlock', function () {
return {
restrict: 'A',
replace: true,
template: '<select ng-model="model" ng-options="item.name for item in items"></select>',
scope: {
model: '=',
items: '='
},
link: function (scope, element, attributes) {
}
}
});