我有對象的數組稱爲presentations
角選擇陣列
我想在select元素使用它們,但它不工作。選擇框只是空白而沒有任何內容。
我想這可能是因爲它想要一個數組或對象,而不是一個對象數組。
我做:
<select ng-model="secondPres" ng-options="p.name for p in presentations" ></select>
我可以CONSOLE.LOG我presentations
陣列和得到這個:
0: Object
name: "club"
origName: "club"
slide: "1"
tenant: "grant"
1: Object
name: "2slide"
origName: "club"
slide: "1"
tenant: "grant"
2: Object
name: "CT_Stress_Test"
origName: "club"
slide: "1"
tenant: "grant"
那麼這是怎麼回事?
這是我的控制器代碼。產生的console.log顯示我上面的內容是在底部。擴大()調用data-ng-init
var socket = io.connect('https://xxxxxxx.xxxxxxxxxxxxx.net:3000');
$scope.versions =[];
$scope.presentations=[];
$scope.secondPres;
$scope.expand = function(){
console.log("expand hit " + presentation1);
var urlToSign = presentation1;
var urlToSign = urlToSign.replace(/^(.*)\/Slide\d_v\d.PNG(.*)/,"$1"+"");
console.log("url to sign = " + urlToSign);
socket.emit('getSignedSlidesFromUrl',urlToSign);
socket.on('signedUrls',function(data){
console.log('got back signedUrls' + data);
$scope.slides=data;
$scope.$apply();
var re = /^.*\/\/.*\/.*\/(.*)/;
var fileName = re.exec(urlToSign)[1];
for(i=0;i<presentationList.length;i++){
var url = presentationList[i];
console.log(url);
var re = /^.*\/\/.*\/(.*)\/.*$/;
var re2 = /^.*\/\/.*\/(.*)\/.*\//;
var re3 =/^.*\/\/.*\/.*\/Slide(\d*)/;
var fileName2 = re.exec(url)[1];
var customerName = re2.exec(url)[1];
var slideNum = re3.exec(url)[1];
$scope.presentations.push({name:fileName2, origName:fileName, tenant:customerName, slide:slideNum});
}
console.log($scope.presentations);
});
};
你能發佈你的控制器代碼嗎? –
這個數組是否來自外部服務而沒有範圍消化? – lib3d
@MikeRobinson完成。 – Houseman