I want to initiate ng-init on page load. I have task.id that fetch with Restangular and my html is:
<textarea rows="5" ng-model="comment.comment_text"></textarea>{{task.id}}
<input type="hidden" ng-model="comment.task_id" ng-init="comment.task_id = $scope.task.id">
<button type="submit" class="btn btn-success" ng-click="create(comment)">Send</button>
and angular controller:
$scope.create = function(comment) {
console.log(comment);
};
When click on button show result in console:
{comment_text: "test", task_id: undefined }
But I want to show like this:
{comment_text: "test" ,task_id:53}
ng-init="comment.task_id = task.id"whithout$scopeng-if="task.id!==undefined". how to resolve problem withoutng-if