我是Materialise的新手,我正在尝试使用angularjs调用该服务并查看materialize select选项中的值。
以下是我的代码:
<div class="input-field">
{{merchantArray.length}}
<select id="merchantssss" ng-model="merchant1.merchantId" ng-options="merchant1.merchantId as merchant1.merchantName for merchant1 in merchantArray" material-select watch>
<option value>Choose Merchant</option>
</select>
</div>
在服务中我收到以下回复:
{"records":[{"merchantId":1,"merchantName":"BSNLs","merchantDesc":"BSNL descs","isActive":"Y"},{"merchantId":4,"merchantName":"Pioneer","merchantDesc":"B","isActive":"Y"},{"merchantId":8,"merchantName":"KFC","merchantDesc":"Test","isActive":"Y"}]}
我无法在select选项中查看值。
任何人都可以指导我如何在select选项中获取值。
控制器:
var merchantList = $http({
url: 'demo/api/v1/merchants',
method: 'GET',
headers: {
"Content-Type": 'application/json',
"X-Auth-Token": cookie
},
})
merchantList.success(function (data, status, response) {
console.log(data.records);
$scope.merchantArray = data.records;
console.log($scope.merchantArray);
}).error(function (data, status, response) {
});
答案 0 :(得分:0)
您选择的模型应该是其他内容。创建一个新的范围变量来保存您的选择
ng-model="merchantSelected"