オブジェクトのプロパティを認識しません:コントローラは、これはMLABで定義された私の製品ドキュメントからの抜粋です
{
"_id": {
"$oid": "596161e1734d1d25634366ce"
},
"images": {
"regular": [
"Amana Electric Range in Stainless Steel-1.jpg",
"Amana Electric Range in Stainless Steel-2.jpg",
"Amana Electric Range in Stainless Steel-3.jpg",
"Amana Electric Range in Stainless Steel-4.jpg",
"Amana Electric Range in Stainless Steel-5.jpg"
]
}
}
これは、マングースの対応機種の抜粋です。
const ProductSchema = new Schema({
images:{}
});
var Product = mongoose.model('Product', ProductSchema, 'product');
module.exports=Product;
私がアクセスしようとしています私のコントローラの画像オブジェクトは次のようになります:
init = function() {
$scope.product = DataService.getProduct();
console.log('productController.product = ', $scope.product)
$mainImage = $scope.product.images.regular[0];
$productImages = $scope.product.images.regular;
};
しかし、私は次のエラーが表示されます:
angular.js:14700 TypeError: Cannot read property 'regular' of undefined
at init (productController.js:8)
at new <anonymous> (
私は角2で同様の問題を持っていたし、私のイメージは私のモデルのいずれかのタイプのオブジェクトを定義することによって、それを解決することができました:
images: any;
どのように私はAngularjsでこれを解決するのですか?
のadditonal情報:getProduct(によって生成
getProduct() {
return $filter('filter')(products, {'_id': productId});
}
製品):
[
{
"_id": "596161e1734d1d25634366ce",
"producttype": "stove",
"name": "30 in. 4.8 cu. ft. Electric Range in Stainless Steel",
"brand": "Amana",
"model": "AER6303MFS",
"price": 199.9,
"list_price": "301.00",
"description": "This 30 in. Amana Electric Range comes with Bake Assist Temps to help you get dinner going. Simply choose a preset temperature setting to get started. Or, set your bake or broil temperatures with Easy Touch Electronic Controls Plus, which are extra-large and easy-to-read. And when you need to know how your dinner is doing without opening the oven door, the Extra-Large Oven Window lets you see and savor.",
"rating": 5,
"sku": "1002064151",
"warranty": "ANSI Certified,CSA Certified",
"images": {
"stainless": [
"Amana Electric Range in Stainless Steel-1.jpg",
"Amana Electric Range in Stainless Steel-2.jpg",
"Amana Electric Range in Stainless Steel-3.jpg",
"Amana Electric Range in Stainless Steel-4.jpg",
"Amana Electric Range in Stainless Steel-5.jpg"
],
"white": [
"Amana Electric Range in White-1.jpg",
"Amana Electric Range in White-2.jpg",
"Amana Electric Range in White-3.jpg",
"Amana Electric Range in White-4.jpg"
],
"black": [
"Amana-black-1.jpg",
"Amana-black-2.jpg",
"Amana-black-3.jpg",
"Amana-black-4.jpg",
"Amana-black-5.jpg"
],
"regular": [
"Amana Electric Range in Stainless Steel-1.jpg",
"Amana Electric Range in Stainless Steel-2.jpg",
"Amana Electric Range in Stainless Steel-3.jpg",
"Amana Electric Range in Stainless Steel-4.jpg",
"Amana Electric Range in Stainless Steel-5.jpg"
]
},
"specifications": {
"dimensions": [
{
"value": "45.25",
"title": "Depth With Door(s) Open 90 Degrees (In.)"
},
{
"value": "25",
"title": "Oven Interior Depth (in)"
},
{
"value": "18.38",
"title": "Oven Interior Height (in)"
},
{
"value": "19",
"title": "Oven Interior Width (in)"
},
{
"value": "27.2",
"title": "Product Depth (in.)"
},
{
"value": "46.25",
"title": "Product Height (in.)"
},
{
"value": "29.88",
"title": "Product Width (in.)"
},
{
"value": "30 in.",
"title": "Range Size"
}
],
"details": [
{
"value": "Gas Range",
"title": "Appliance Type"
},
{
"value": "Cast Iron",
"title": "Burner Grate Material"
},
{
"value": "9500",
"title": "Burner No.1 BTU"
},
{
"value": "15000",
"title": "Burner No.2 BTU"
},
{
"value": "5000",
"title": "Burner No.3 BTU"
},
{
"value": "15000",
"title": "Burner No.4 BTU"
},
{
"value": "5.1",
"title": "Capacity of Oven (cu. ft.)"
},
{
"value": "Manual Clean",
"title": "Cleaning Type"
}
]
},
"feature": [
"Large 4.8 cu. ft. oven capacity with space for dinner and dessert",
"Versatile cooktop with multiple element options up to 1,800 watts",
"Bake Assist Temp presets make cooking even more convenient"
],
"$$hashKey": "object:181"
は} ]
$ scope.productログとは何ですか? –
対象製品をログに記録しています。 – koque
私はそれを理解していますが、ログに記録された結果を表示して、その場所に間違いを犯している場所を教えてください。 –