Last active
August 15, 2017 16:28
-
-
Save kauffmanes/3d5e8d5f1ad08d9bba15a70ba396fb6b to your computer and use it in GitHub Desktop.
Form Controller 1
This file contains 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('app', []); | |
app.controller('FormController', ['$scope', function ($scope) { | |
$scope.questions = []; | |
//Again, can be fired on a button click, on page load, etc. | |
$scope.getQuestions = function (type) { | |
var type = type ? type : 'default'; //some kind of validation can go here | |
//make service call based on category and return questions | |
$http({ | |
method: 'GET', | |
url: '/forms', | |
params: { name: type } | |
}).then(function (res) { | |
//Parse response to get just questions collection | |
$scope.questions = res && res.data && res.data.questions; | |
})['finally'](function (err) { | |
//Error handling | |
}); | |
}; | |
$scope.submit = function () { | |
//submit form data | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment