Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch json from database #24

Open
bravojohny91 opened this issue May 20, 2016 · 1 comment
Open

Fetch json from database #24

bravojohny91 opened this issue May 20, 2016 · 1 comment

Comments

@bravojohny91
Copy link

var myApp = angular.module('myApp', ['fg', 'ngSanitize', 'markdown']);

var myData;

myApp.controller('MyController', function ($scope, mySchema, formService) {

formService.GetCountyForm('', '').then(function (d) {
    myData = d.data[0].FormSchema;
    schema = myData;
    //alert(myData);  Contains json from database
});

$scope.myForm = {
    schema: myData
};

$scope.init = function (value) {
    alert(myData);
    $scope.testInput = myData;
}

});

myApp.value('mySchema',myData);

myApp.factory('formService', function ($http) {
var fac = {};

fac.GetCountyForm = function (stateCode, countyName) {
    //alert($(".select4 :selected").text() + " " + countyName);
    //replacing statecode with statename

    return $http({
        url: '/data/GetFormSchema',
        method: 'POST',
        data: JSON.stringify({stateCode: stateCode, countyName: countyName }),
        headers: { 'content-type': 'application/json' }
    });
}


return fac;

});

My Html looks like

Example Form
                        <!-- Magic ends here -->
                    </fieldset>
                    @*<div ng-include="'form-status.html'"></div>*@
                    <div>
                        <button type="submit"
                                class="btn btn-primary"
                                ng-class="{ disabled: previewForm.$invalid }">
                            Submit
                        </button>
                    </div>
                </form>
            </div>

I am getting the json from database, but somehow not getting loaded for the form, I must be missing something, can you help me out with this? Thanks

@cristid9
Copy link

I have the same problem. How did you solve it (if you did and forgot to post)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants