I want to pass a product's id to a directive like so:
<widget product-id="product.id"></widget>
I prefer not to use curly braces:
<widget product-id="{{product.id}}"></widget>
because it's more verbose, and I want to match the style of ng-model usage.
I want to use isolate scope so that I can't accidentally modify product.id inside the widget.
If I use:
scope {
productId: '@'
}
Then in my directive template: {{productId}} gives me the string "product.id"
If I use:
scope {
productId: '&'
}
I see no output in my directive template {{productId}}, and as I understand it & is for binding functions not properties.
If I use:
scope {
productId: '='
}
I get the exact value that I want (a number), but isn't this two-way binding and vulnerable to changing the product.id in the widget?