Angular ngOptions Dropdown' Undefined'

时间:2016-09-11 05:49:14

标签: javascript html angularjs

首先:



.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;
&#13;
&#13;

有我的代码。我将一个主题列表放入名为topics的下拉菜单中。当我将topicList放入下拉列表中时,我会得到几个undefined。但是当我console.log (topicList)数据是正确的时候。为什么我把它放在我的html下拉列表中,数据是undefined

0 个答案:

没有答案