Last active
March 6, 2016 14:22
-
-
Save hahalin/1168f43c2bb80ba70711 to your computer and use it in GitHub Desktop.
angularjs populate select option data from ajax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var app = angular.module('BpmApp', []) | |
| app.controller('regctrl', function ($scope, CompanyService) { | |
| getCompanies(); | |
| $scope.selectedCompany = "1"; | |
| function getCompanies() { | |
| CompanyService.getCompanies() | |
| .success(function (ds) { | |
| $scope.companies = ds; | |
| }) | |
| .error(function (error) { | |
| $scope.status = 'Unable to load company data: ' + error.message; | |
| console.log($scope.companies); | |
| }); | |
| } | |
| }); | |
| app.factory('CompanyService', ['$http', function ($http) { | |
| var CompanyService = {}; | |
| CompanyService.getCompanies = function () { | |
| return $http.get('/Company/List'); | |
| }; | |
| return CompanyService; | |
| }]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment