Created
March 16, 2016 07:20
-
-
Save blacktambourine/1c5369774651dca9bb75 to your computer and use it in GitHub Desktop.
example angular controller
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 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