我正在使用代码学校的angularJS教程,我的代码在我的网页上错误地渲染。非常感谢任何帮助。这是我的index.html和app.js代码:
用于index.html:
<!DOCTYPE html>
<html ng-app="store">
<head>
<meta charset="utf-8" />
<title>My Angular App</title>
<link rel="stylesheet" type="text/css" href="bootstrap.min.css"/>
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body ng-controller="StoreController as store">
<div ng-repeat="product in store.products">
<h1>{{product.name}}</h1>
<h2>${{product.price}}</h2>
<p>{{product.description}}</p>
<button ng-show="store.product.canPurchase"> Add to Cart </button>
</div>
</body>
</html>
对于app.js:
(function() {
var app = angular.module('store', []);
app.controller('StoreController', function(this){
this.products = gems;
});
var gems = [
{ name: 'Dodecahedron',
price: 2.95,
description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
images: [
{
full: 'dodecahedron-01-full.jpg',
thumb: 'dodecahedron-01-thumb.jpg'
}]
canPurchase: false
soldOut: false
},
{
name: "Pentagonal Gem",
price: 5.95,
description: "..."
canPurchase: true,
soldOut: false
}
];
})();
答案 0 :(得分:0)
你有两个问题:
1)您不需要将“this”作为参数添加到控制器创建中的函数中:
db.collection.aggregate([ {$match: ... }, {$group: ... }])
2)数据中存在多个拼写错误(缺少逗号),导致Javascript无法解析。
Mat rotateImage(Mat im, double angle){
cv::Matx23d rot = getRotationMatrix2D(cv::Point2f(im.cols/2,im.rows/2),angle,1);
cv::Matx31d tl(0,0,1);
cv::Matx31d tr(im.cols,0,1);
cv::Matx31d bl(0,im.rows,1);
cv::Matx31d br(im.cols,im.rows,1);
std::vector<cv::Point2f> pts;
cv::Matx21d tl2 = rot*tl;
cv::Matx21d tr2 = rot*tr;
cv::Matx21d bl2 = rot*bl;
cv::Matx21d br2 = rot*br;
pts.push_back(cv::Point2f(tl2(0),tl2(1)));
pts.push_back(cv::Point2f(tr2(0),tr2(1)));
pts.push_back(cv::Point2f(bl2(0),bl2(1)));
pts.push_back(cv::Point2f(br2(0),br2(1)));
cv::Rect bounds = cv::boundingRect(pts);
cv::Matx33d tran(1,0,(bounds.width-im.cols)/2,0,1,(bounds.height-im.rows)/2,0,0,1);
cv::Matx33d rot33;
for(int i = 0; i < 2; i++)
for(int j=0; j<3; j++)
rot33(i,j) = rot(i,j);
rot33(2,0) = 0;
rot33(2,1) = 0;
rot33(2,2) = 1;
cv::Matx33d combined = tran*rot33;
cv::Matx23d finall;
for(int i = 0; i < 2; i++)
for(int j=0; j<3; j++)
finall(i,j) = combined(i,j);
cv::Size im_size(bounds.width,bounds.height);
Mat drawing_image;
cv::warpAffine(im, drawing_image,finall, im_size);
return drawing_image;
}