I have directive in my Angular code. It has isolated scope binded to attributes of element; changing model controller; postlink function designed to bind click callbacks to elements in template; template with ng-switch.
scope: {
payload: '='
},
controller: function($scope){
$scope.havePayload = $scope.payload;
},
link: {
post: function(scope, elem, attrs){
elem.children(".with-payload").css( "background-color", "red" );
}
},
restrict: 'A',
replace: true,
template: '<div ng-switch on="havePayload"> \
<div ng-switch-when="true" class="with-payload"></div> \
<div ng-switch-when="false" class="without-payload"></div> \
</div>'
The problem is that when postlink starts, ng-switch still doesn't know anything about model and doesn't include in DOM elements that I need in postlink. It's strange, because postlink should be executed only when template is agreed with model.
Here is jsfiddle example. Looks strange, I know. Just my poor fantasy :)
Update
(http://jsfiddle.net/NXQ8G/3/)
Doesn't seem to work.