Уважаемое сообщество! Мне нужно указать значение компании в ng-model в поле. Я пробовал разные способы. Html код:
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr ng-repeat="d in matilda" ng-class-odd="odd" ng-class-even="even">
<td>{{d.Company}}</td>
<td>{{d.Contact}}</td>
<td>{{d.Country}}</td>
<td class="checkbox">
<label><input type="checkbox" ng-true-value="d.Company" ng-false-value="''" ng-model="key"></label>
</td>
</tr>
</table>
<div class="row">
<div class="col-md-4 col-xs-3">
<button class="button" ng-click="get();">View</button>
</div>
<div class="col-md-4 col-xs-3">
<button type="button" class="button" data-toggle="modal" data-target="#exampleModal">
Add
</button>
</div>
<div class="col-md-4 col-xs-3">
<button class="button" ng-click="del();">Delete</button>
</div>
</div>
angular код: // установить начальное значение
angular.module('MyApp', [])
var app = angular.module('myApp', []);
app.controller('TableController', ['$scope', '$rootScope', '$http', function ($scope, $rootScope, $http) {
$scope.getdeat = "";
$scope.Company = "";
$scope.Contact = "";
$scope.Country = "";
$scope.key = "";
$scope.get = function () {
alert("con");
try {
$http({
method: 'POST',
data: {},
url: '/Home/Login',
timeout: httpTimeout,
}).then(function successCallback(response) {
$scope.matilda = response.data;
}, function errorCallback(response) {
alert("error");
});
}
catch (ex) {alert(ex); }
}
$scope.add = function () {
alert($scope.Company);
var reg = { Company: $scope.Company, Contact: $scope.Contact, Country: $scope.Country };
try {
$http({
method: 'POST',
data: reg,
url: '/Home/AddValue',
timeout: httpTimeout,
}).then(function successCallback(response) {
var maxi = response.data;
var code = maxi.Code;
if (code == "1") {
alert("Table Updated");
}
}, function errorCallback(response) {
alert("error");
});
}
catch (ex) { alert(ex); }
}
$scope.del = function () {
// set initial value
alert($scope.isChecked);
try {
$http({
method: 'POST',
data: $scope.key,
url: '/Home/AddValue',
timeout: httpTimeout,
}).then(function successCallback(response) {
var maxi = response.data;
var code = maxi.Code;
if (code == "1") {
alert("Table Updated");
}
}, function errorCallback(response) {
alert("error");
});
}
catch (ex) { alert(ex); }
}
}]);
Предупреждение показывает '' и не определено, я новичок, укажите где я сделал ошибку, я делаю какую-либо ошибку в секции ng-repeat или в моей секции js?