Creating an update form using a route parameter to fetch the item's ID is functioning correctly. A crucial part of this update form is fetching stored values and binding them to the form.
When setting my model like this:
<input type="text" class="form-control" id="Event_Desc" data-ng-model="eventdescription" required />
And defining my controller as shown below (noting that it calls a REST service using ng-resource).
appItem.get({
Id: $routeParams.Id
}, function (result) {
$scope.eventdescription = result.Title;
});
The field value will be correctly set to the database value on the form. However, when attempting to use vm. notation as follows, it throws an error "Unable to set property 'eventdescription' of undefined or null reference"
HTML:
<input type="text" class="form-control" id="Event_Desc" data-ng-model="vm.eventdescription" required />
Controller:
appItem.get({
Id: $routeParams.Id
}, function (result) {
$scope.vm.eventdescription = result.Title;
});
Why am I unable to set the $scope of vm.eventdescription?