[英]Why aren't the values from my directive being passed into the function?
Here is my directive:这是我的指令:
function OrderCloudRepeatOrderDirective() {
return {
restrict: 'E',
templateUrl: 'orderHistory/templates/repeatOrder.tpl.html',
controller: 'RepeatOrderCtrl',
controllerAs: 'repeat',
scope: {
orderid: '=',
includeBilling: '@',
includeShipping: '@'
}
}
}
Here is view for my directive:这是我的指令的视图:
<div class="btn btn-success" ng-click="repeat.reorder(orderid, includeBilling, includeShipping)" >Reorder</div>
Here it is actually in the HTML:这里实际上是在 HTML 中:
<ordercloud-repeat-order orderid="order.ID" includeBilling="true" includeShipping="true"></ordercloud-repeat-order>
Then I simply have a function tied to the ng-click directive that performs the logic.然后我只是有一个与执行逻辑的 ng-click 指令相关联的函数。 I realize the '@' values come back as a string and have accommodated for that.
我意识到“@”值作为字符串返回并已适应。 The orderID value comes through fine but when I step through my function I see that the other two values are undefined.
orderID 值很好,但是当我逐步执行我的函数时,我发现其他两个值未定义。 Any ideas?
有任何想法吗?
By naming convention (the capitalization of subsequent words) Angular is adding a dash to your parameter names when used as the HTML attribute of your element.通过命名约定(后续单词的大写),当用作元素的 HTML 属性时,Angular 会在参数名称中添加一个破折号。
includeBilling
is used as include-billing="true"
includeBilling
用作include-billing="true"
includeShipping
is used as include-shipping="true"
includeShipping
用作include-shipping="true"
Note you defined the orderid
scope variable as entirely lowercase which is why that one is working as is.请注意,您将
orderid
范围变量定义为完全小写,这就是该变量按原样工作的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.