Я пытаюсь сделать сообщение из модального. Я получаю сообщение об ошибкеНе могу прочитать свойство '' of null
Не удается прочитать свойство «CustomerPhoneNumber» нулевых
все отлично работает, когда я удалить selectedCustomer. часть ng-моделей. Мне нужно заставить его работать, как есть. Не знаете, как заставить его считывать входные значения.
//Post New Customer
$scope.submitCustomer = function() {
var data = {
CustomerId: $scope.selectedCustomer.CustomerId,
CustomerPhoneNumber: $scope.selectedCustomer.CustomerPhoneNumber,
CustomerName: $scope.selectedCustomer.CustomerName,
CustomerFaxNumber: $scope.selectedCustomer.CustomerFaxNumber,
CustomerAddress: $scope.selectedCustomer.CustomerAddress,
CustomerCity: $scope.selectedCustomer.CustomerCity,
CustomerState: $scope.selectedCustomer.CustomerState,
CustomerZipcode: $scope.selectedCustomer.CustomerZipcode,
CustomerWebsite: $scope.selectedCustomer.CustomerWebsite,
CustomerOtherShit: $scope.selectedCustomer.CustomerOtherShit,
CustomerHidden: $scope.selectedCustomer.CustomerHidden,
CustomerPM: $scope.selectedCustomer.CustomerPM,
CustomerAdmin: $scope.selectedCustomer.CustomerAdmin,
CustomerAccountant: $scope.selectedCustomer.CustomerAccountant,
CustomerSuperintendent: $scope.selectedCustomer.CustomerSuperintendent
}
$http.post('/api/apiCustomer/PostNewCustomer', data).success(function (data, status, headers) {
console.log(data); window.top.location.reload();
});
};
<form ng-submit="submitCustomer()" enctype="multipart/form-data">
<tabset>
<tab heading="CustomerList">
<div class="col-xs-12" style="margin-top:5px">
<div style="overflow: auto;height:200px" id="scrollAreaCustomers">
<table class="table">
<tr>
<th style="font-weight: bold;">Name</th>
</tr>
<tr><input type="text" placeholder="New Customer" ng-model="selectedCustomer.CustomerName" ng-enter="data.static = true" /></tr>
<tr ng-repeat="customer in customerArray | filter:searchCustomerName" class="pointer">
<td ng-click="setSelectedCustomer(customer);data.static = true">{{customer.CustomerName}}</td>
</tr>
</table>
</div>
</div><!--End col-xs-12-->
</tab><!--End CustomerList Tab-->
<tab heading="CustomerDetails" active="data.static">
<div class="col-xs-12" style="margin-top:5px">
<div class="inline-fields">
<label>Name:</label>
<input style="width:150px;margin-left:19px" type="text" ng-model="selectedCustomer.CustomerName" />
<label style="margin-left: 80px">Website:</label>
<input style="width:150px" type="text" ng-model="selectedCustomer.CustomerWebsite" />
</div>
<div class="inline-fields">
<label style="margin-left:1px;">Address:</label>
<input style="width:180px" ng-model="selectedCustomer.CustomerAddress" type="text">
</div>
<div class="inline-fields">
<label style="margin-left: 30px">City:</label>
<input style="width:80px;" ng-model="selectedCustomer.CustomerCity" type="text">
<label>State:</label>
<input style="width:30px" ng-model="selectedCustomer.CustomerState" type="text">
<label>Zipcode:</label>
<input style="width:50px" ng-model="selectedCustomer.CustomerZipcode" type="text">
</div>
<div class="inline-fields">
<label style="margin-left: 14px">Phone:</label>
<input style="width:121px;" ng-model="selectedCustomer.CustomerPhoneNumber" type="text">
<label>Fax:</label>
<input style="width:115px" ng-model="selectedCustomer.CustomerFaxNumber" type="text">
</div>
</div><!--End col-xs-12-->
</tab>
<tab heading="CustomerEmployees">
<div class="col-xs-12" style="margin-top:5px">
<div class="inline-fields" style="">
<label style="margin-left:49px">PM:</label>
<input style="width:150px" ng-model="selectedCustomer.CustomerPM" type="text">
</div>
<div class="inline-fields" style="">
<label style="margin-left:26px">Admin:</label>
<input style="width:150px" ng-model="selectedCustomer.CustomerAdmin" type="text">
</div>
<div class="inline-fields" style="">
<label style="margin-left:1px">Acountant:</label>
<input style="width:150px" ng-model="selectedCustomer.CustomerAccountant" type="text">
</div>
<div class="inline-fields" style="">
<label style="margin-left:30px">Super:</label>
<input style="width:150px" ng-model="selectedCustomer.CustomerSuperintendent" type="text">
</div>
</div>
</tab>
</tabset><!--End Tab Content-->
<div class="col-xs-12">
<input style="margin-left:360px;margin-top:25px;width:70px" type="submit" value="Save" go-click="#" />
<input style="margin-left: 20px; width: 70px; margin-top: 25px" type="button" data-dismiss="modal" value="Exit" go-click="#" />
</div>
</form>
Обновленный
TypeError: Cannot read property 'CustomerId' of null
at Scope.$scope.submitCustomer (http://localhost:44301/MyScripts/JobController.js:255:48)
at http://localhost:44301/Scripts/angular.js:10836:21
at http://localhost:44301/Scripts/angular.js:19094:17
at Scope.$eval (http://localhost:44301/Scripts/angular.js:12673:28)
at Scope.$apply (http://localhost:44301/Scripts/angular.js:12771:23)
at HTMLFormElement.<anonymous> (http://localhost:44301/Scripts/angular.js:19093:21)
at HTMLFormElement.x.event.dispatch (http://localhost:44301/Scripts/jquery-1.10.2.min.js:22:14129)
at HTMLFormElement.v.handle (http://localhost:44301/Scripts/jquery-1.10.2.min.js:22:10873) angular.js:10061(anonymous function) angular.js:10061(anonymous function) angular.js:7357Scope.$apply angular.js:12773(anonymous function) angular.js:19093x.event.dispatch jquery-1.10.2.js:9789v.handle
Я рекомендую поместить это в jsfiddle или plunkr. У вас гораздо больше шансов получить быструю помощь, если вы это сделаете. –
обычно я бы, но я не уверен, как установить POST, чтобы дать ту же ошибку. Вот вопрос из предыдущего вопроса, с которым я имел помощь. Это то, что я использую сейчас. http://plnkr.co/edit/9SkOWYEQt5dAGPwKbEOW?p=preview – texas697
В вашем плунтере есть случаи, которые смешивают «customerName» с «CustomerName», но это не приведет к ошибке, которую вы получаете. Сообщение также не является причиной этой ошибки, поскольку строка сообщения не ссылается на CustomerPhoneNumber. Вам нужно разместить больше информации (опять же, я рекомендую подходящий плункер), если вы хотите получить точную помощь. –