I made a directive to display a script tag in my view:
angular.module 'app'
.directive 'kwankoScript', ->
restrict: 'E'
replace: true
template: '<script type="text/javascript">
window.ptag_params = {
zone: "transaction",
transactionId: "id",
currency: "EUR",
customerId: "' + scope.user.uuid + '",
siteType: "d"
};
</script>'
I call this directive from my view dashboard-validate.html like so:
<kwanko-script></kwanko-script>
I can access {{transaction.uuid}} from the view, but I cannot from my directive.
I would like to replace transactionId: "id" by
`transactionId: "{{transaction.uuid}}" but it doesn't work.
any help would be greatly appreciated.
UPDATED :
this is my directive now:
angular.module 'paycarApp'
.directive 'kwankoScript', ->
restrict: 'E'
replace: true
scope:
transaction-id: "="
template: '<script type="text/javascript">
window.ptag_params = {
zone: "transaction",
transactionId: {{ transaction-id }},
currency: "EUR",
customerId: "' + scope.user.uuid + '",
siteType: "d"
};
</script>'
and my view:
<kwanko-script transaction-id="{{transaction.uuid}}"></kwanko-script>
If I don't put the curly braces, the directive is not executed
and this is the output
<script type="text/javascript" transaction-id="" class="ng-scope">
window.ptag_params = {
zone: "transaction",
transactionId: {{ transaction-id }},
currency: "EUR",
customerId: "7514c32b-0aec-1b00-a52d-e676ff62e297",
siteType: "d" };
</script>
<div>and that still doesn't work. can I maybe send you a direct message ?{{user.uuid}}it doesn't work anymore. is there a reason for that ?userId: "=", which means it will allready evaluate the variable and therefore the{{}}aren't necessary anymore.