[英]Why aren't the changes to my variable being visible outside of this function?
[英]Why aren't the values from my directive being passed into the function?
這是我的指令:
function OrderCloudRepeatOrderDirective() {
return {
restrict: 'E',
templateUrl: 'orderHistory/templates/repeatOrder.tpl.html',
controller: 'RepeatOrderCtrl',
controllerAs: 'repeat',
scope: {
orderid: '=',
includeBilling: '@',
includeShipping: '@'
}
}
}
這是我的指令的視圖:
<div class="btn btn-success" ng-click="repeat.reorder(orderid, includeBilling, includeShipping)" >Reorder</div>
這里實際上是在 HTML 中:
<ordercloud-repeat-order orderid="order.ID" includeBilling="true" includeShipping="true"></ordercloud-repeat-order>
然后我只是有一個與執行邏輯的 ng-click 指令相關聯的函數。 我意識到“@”值作為字符串返回並已適應。 orderID 值很好,但是當我逐步執行我的函數時,我發現其他兩個值未定義。 有任何想法嗎?
通過命名約定(后續單詞的大寫),當用作元素的 HTML 屬性時,Angular 會在參數名稱中添加一個破折號。
includeBilling
用作include-billing="true"
includeShipping
用作include-shipping="true"
請注意,您將orderid
范圍變量定義為完全小寫,這就是該變量按原樣工作的原因。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.