我有這樣的代碼:呼叫JavaScript功能時
<ion-content>
<ion-list>
<ion-item > 訂單號 餐桌 顧客姓名 顧客電話號碼 配送地址 訂單備註 下單時間 </ion-item>
<ion-item ng-repeat="x in orders|orderBy:'order_id'">
{{ x.order_id + ', ' + x.table_id+', '+x.name+', '+x.phone+', '+x.address+', '+x.remark+', '+changTimetoString(x.ctime)}}
<button onclick="window.viewOrderDetails(x.detail)">Order detail</button>
</ion-item>
</ion-list>
</ion-content>
在app.js:
app.controller('customersController', ['$scope', '$http', function($scope,$http) {
$http.get("http://18ff2f50.tunnel.mobi/yii2-basic/tests/Customers_JSON.json")
.success(function (response)
{
console.log("debug",response);
$scope.orders = response;
});
window.viewOrderDetails = function viewOrderDetails(detail) {
var newWin = open('orderdetails.html','windowName','height=300,width=300');
newWin.document.write('html to write...');
newWin.document.write(detail);
}
欲x.detail作爲窗口的輸入參數。查看訂單詳情。
但是,當我點擊按鈕「訂單明細」,它說「x未定義」。 我想知道問題在哪裏。謝謝。
你能說明代碼是「訂單」嗎? – OceansOnPluto
爲什麼你需要'onclick'在角度應用程序的中間? – charlietfl
你可以用'ng-click'替換'onclick'嗎?另外儘量不要使用window作爲你的controllerAs名字,一般window.something在javascript中有特殊的含義。 – Icycool