Fiddle: http://jsfiddle.net/zorro/U8HpP/2/
Below code does not work. If I remove the transclude and template, it works just as intended. What am I missing?
<div ng-app="example">
<div ng-controller="TodoCtrl">
<div ng-repeat="car in carsOwned">
<h3>Owned car: {{car.brand}}</h3>
<div example-select ng-model="car">
<select ng-model="car" ng-options="carType.brand for carType in carTypes"></select>
<p>Why doesn't the select alter the owned car?</p>
</div>
</div>
</div>
function TodoCtrl($scope) {
$scope.carTypes = [{
brand: 'BMW',
value: 'bmw'
}, {
brand: 'Mercedes',
value: 'me'
}, {
brand: 'Fiat',
value: 'fi'
}];
$scope.carsOwned = [$scope.carTypes[0]];
}
angular.module('example', []).directive('exampleSelect', function () {
return {
transclude: true,
scope: {
car: '='
},
link: function (scope, elm, attrs, ctrl) {
console.log('alive');
},
template: '<div ng-transclude></div>'
};
});