Last active
July 12, 2018 02:34
-
-
Save travist/293063135cf0c58eb78354c95f7a8378 to your computer and use it in GitHub Desktop.
Auto-populate a field with data
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
FormioResourceProvider.register('todo', AppConfig.forms.todoForm, { | |
defaultValue: {data: {status: 'notstarted'}}, | |
templates: { | |
view: 'views/todo/view.html' | |
}, | |
controllers: { | |
create: ['$scope', '$rootScope', function($scope, $rootScope) { | |
$rootScope.whenReady.then(function() { | |
$scope.submission = {data: { | |
email: $rootScope.user.data.email | |
}}; | |
}); | |
}], | |
view: ['$scope', function($scope) { | |
$scope.position = {lat: '40.74', lng: '-74.18'}; | |
$scope.currentResource.loadSubmissionPromise.then(function() { | |
if (!$scope.currentResource.resource) { return; } | |
if ($scope.currentResource.resource.data.address) { | |
$scope.position.lat = $scope.currentResource.resource.data.address.geometry.location.lat; | |
$scope.position.lng = $scope.currentResource.resource.data.address.geometry.location.lng; | |
} | |
}); | |
}] | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment