所以我在这里有一个完整的应用程序是一个向下运行:
I = imread('cameraman.tif');
I = im2double(I);
T = dctmtx(8); % dct matrix
%Performing DCT on blocks of 8 by 8
dct = @(block_struct) T * block_struct.data * T';
B = blockproc(I,[8 8],dct);
B = ceil(B);
% A Standard Quantization Matrix
q_mtx = [16 11 10 16 24 40 51 61;
12 12 14 19 26 58 60 55;
14 13 16 24 40 57 69 56;
14 17 22 29 51 87 80 62;
18 22 37 56 68 109 103 77;
24 35 55 64 81 104 113 92;
49 64 78 87 103 121 120 101;
72 92 95 98 112 100 103 99];
%PErforming Quantization by Dividing with q_mtx on blocks of 8 by 8
c = @(block_struct) (block_struct.data) ./ q_mtx;
B2 = blockproc(B,[8 8],c);
% B2 = ceil(B2)
%Performing Inverse Quantization By Multiplying with q_mtx on Blocks of 8
%by 8
B3 = blockproc(B2,[8 8],@(block_struct) q_mtx .* block_struct.data);
%Performing Inverse DCT on Blocks of 8 by 8
invdct = @(block_struct) T' * block_struct.data * T;
% B3 = ceil(B3);
I2 = blockproc(B3,[8 8],invdct);
imshow(I), figure, imshow(I2)
所以在ul div类扇区中,我有{{1 * contact.quantity - contact.sold}},当我输入数字时它会减去但是如何将更新后的数字存储到我的数据库中。这是我想要使用的控制器功能。
控制器:
<table class="table">
<thead>
<tr>
<th>Photo</th>
<th>Item Name</th>
<th>Price</th>
<th>Quantity</th>
<th>Action</th>
<th>Edit update</th>
</tr>
</thead>
<tbody>
<tr>
<td><input class="form-control" ng-model="contact.photo"></td>
<td><input class="form-control" ng-model="contact.name"></td>
<td><input class="form-control" ng-model="contact.price"></td>
<td><input class="form-control" ng-model="contact.quantity"></td>
<td><button class="btn btn-primary" ng-click="addContact()">Add Item</button></td>
<td><button class="btn btn-info" ng-click="update()">Update</button></td>
</tr>
</tbody>
</table>
<ul ng-repeat="contact in contactlist" class="items-ul">
<li>
<div class="sector"><img class='photo-display'>{{contact.photo}}</img></div>
<div class="sector">
<p class="info-mid"><span style="font-size:30px; padding:0px;">{{contact.name}}</span></p>
<p class="info-mid"><span style="color:deepskyblue;">Price: </span>{{1 * contact.price}}</p>
<p class="info-mid"><span style="color:deepskyblue;">Quantity Remaining: </span>{{1 * contact.quantity}}</p>
</div>
<div class="sector">
<p style="font-size:18px; padding:10px 0px 0px 0px;">Total: <span style="color:lightgreen;">${{contact.quantity * contact.price}}</span></p>
<hr>
Sold: <input class="form-control" ng-model="contact.sold"><button class="btn btn-primary" ng-click="addSold()">Enter</button>
<p>{{1 * contact.quantity - contact.sold}}</p>
<br>
<p><button class="btn btn-danger" ng-click="remove(contact._id)">X</button><button class="btn btn-warning" ng-click="edit(contact._id)">Edit</button></p>
</div>
</li>
</ul>
服务器js put:
$scope.addSold = function(id){
console.log(id);
$http.put('/contactlist' + $scope.contact._id, $scope.contact.sold).success(function(response){
refresh();
});
};
我认为我的错误是在server.js中,但我在Angular和Node中并不是很先进,所以我不知道如何实现这一点。谢谢你