Skip to content

Instantly share code, notes, and snippets.

@iamdtang
Created September 9, 2015 17:01
Show Gist options
  • Save iamdtang/5778bdddc8d70f111432 to your computer and use it in GitHub Desktop.
Save iamdtang/5778bdddc8d70f111432 to your computer and use it in GitHub Desktop.
angular
.module('defaultValueSelect', [])
.controller('ExampleController', function($scope, someCalculationService) {
$scope.data = {
availableOptions: [
{id: '1', name: 'Option A'},
{id: '2', name: 'Option B'},
{id: '3', name: 'Option C'}
],
selectedOption: {id: '3', name: 'Option C'} //This sets the default value of the select in the ui
};
$scope.calculate = function(val) {
console.log('hey', $scope.data.selectedOption);
var calculatedData = someCalculationService.calculate($scope.data.selectedOption);
};
})
.factory('someCalculationService', function() {
return {
calculate: function() {
return [];
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment