Is it possible when creating a custom directive to have an attribute which can be a string or two way bound to something on the scope?
So, for example if I have this in my directive declaration:
$scope: {
position: '=?'
}
and then alert it in my link function or controller:
$alert($scope.position);
It works if I actually bind it to something on my parent scope, but if I just put a string in I get undefined unless I use single quotes inside the double quotes. E.g.
<my-directive position="'right'"></my-directive>
That way it evaluates the expression as a string, but It seems ugly. I'd rather be able to use position="right" when I want to give the attribute a string, or use position="{{scopeVariable}}" when I want to bind it to two way bind it to something in the parent controller.
Am I wrong to be using "=?" as the isolate scope binding? Is there a better way to do this? Or should I just get used to using single quotes inside double quotes?