I have code like this:
<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>
In 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);
}
I want x.detail as an input parameter for window.viewOrderDetails.
But when I click button "Order detail", it's said "x is not defined". I want to know where problem is. Thanks.
onclickin the middle of an angular app?onclickwithng-click? Also try not to use window as your controllerAs name, generally window.something has special meaning in javascript.