angular.module('gm.typeaheadDropdown', ['ui.bootstrap'])
.directive('typeaheadDropdown', function() {
	return {
		templateUrl:'templates/typeaheadDropdown.tpl.html',
		scope: {
			model:'=ngModel',
			getOptions:'&options',
			config:'=?',
			required:'=?ngRequired'
		},
		replace:true,
		controller: ['$scope', '$q', function($scope, $q) {
			$scope.config = angular.extend({
				modelLabel:"name",
				optionLabel:"name"
			}, $scope.config);

			$q.when($scope.getOptions())
			.then(function(options) {
				$scope.options = options;
			});

			$scope.onSelect = function($item, $model, $label) {
				angular.extend($scope.model, $item);
				$scope.model[$scope.config.modelLabel] = $item[$scope.config.optionLabel];
			}
		}]
	}
})
@@ -590,24 +590,70 @@
 , $label) %7B%0A
+%09%09%09%09if(!$scope.model)%0A%09%09%09%09%09$scope.model = %7B%7D;%0A
 %09%09%09%09angular.

Fix bug if model is initially null.