Skip to content

Instantly share code, notes, and snippets.

@blacktambourine
Created March 16, 2016 07:20
Show Gist options
  • Save blacktambourine/1c5369774651dca9bb75 to your computer and use it in GitHub Desktop.
Save blacktambourine/1c5369774651dca9bb75 to your computer and use it in GitHub Desktop.
example angular controller
var accordionModule = angular.module('corpApp.accordionContentModule', ['ngRoute']);
accordionModule.controller('AccordionContentCtrl', ['$scope', '$controller', 'AccordionContentService', function ($scope, $controller, AccordionContentService) {
$scope.populatePageData = function (itemId)
{
$scope.callWebApiService(AccordionContentService, { id: itemId })
.then(function (result)
{
$scope.HandleResponseErrors(result);
$scope.data.groups = result.AccordionSections;
return true; //canContinue, always return a value when using .then()
},
function () { $scope.onSubmitFail(); });
}
//initialise page
$scope.init = function (itemId)
{
//inherit from base controller
angular.extend(this, $controller('BaseCtrl', { $scope: $scope }));
$scope.data = {};
$scope.populatePageData(itemId);
}
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment