How can I effectively inject my JSON Object into my angular $scope during the create() function?
Sample HTML:
<input type="text" class="title" placeholder="hold" ng-model="formData.text"/>
<input type="text" class="desc" placeholder="description" ng-model="formData.desc"/>
<button type="submit" class="btnCreate" ng-click="createRule();direction('front');go('/myrules')">CREATE
</button>
Controller code:
$http.get('/public/mdm/default.json').success(function (data) {
$scope.data = data;
console.log($scope.data);
})
$scope.formData = {};
$scope.createRule = function () {
Rules.create($scope.formData)
.success(function (data) {
$scope.formData = {};
$scope.rules = data;
// Now, how do I properly add my JSON to this creation...
});
};
The issue lies in populating $scope.formData with an Object where push() cannot be used...
$scope.formData[JSONObject] = $scope.data;
is not working as expected.
I believe there must be a simpler way to accomplish this task. Any assistance or guidance on this matter would be greatly appreciated. Thank you in advance!