首先:
.controller('HomeCtrl', function($scope, $rootScope, $http, $ionicPlatform) {
// This disables the user from being able to go back to the previous view
$ionicPlatform.registerBackButtonAction(function (event) {
event.preventDefault();
}, 100);
console.log("Getting Profile");
var temp = window.localStorage.getItem("UserProfile");
var profile = JSON.parse(temp);
var topicList = [];
for (var i = 0; i < profile.UserTopics.length; i++) {
var topicName = profile.UserTopics[i].topicName;
topicList.push(topicName);
}
$scope.topics = topicList;
&#13;
有我的代码。我将一个主题列表放入名为topics
的下拉菜单中。当我将topicList
放入下拉列表中时,我会得到几个undefined
。但是当我console.log (topicList)
数据是正确的时候。为什么我把它放在我的html下拉列表中,数据是undefined
?