如何修复我的代码? angularjs,ejs代码 [英] how to fix my code?? angularjs, ejs code

查看:79
本文介绍了如何修复我的代码? angularjs,ejs代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了angular js和ejs。
重复是很好的,但是数据库数据不会输入。

I used angular js and ejs. Repeat is good but, Database data does not come in.

我应该如何修复代码?

在此angularjs代码中

In this angularjs code

var app = angular.module('myApp', []);
app.controller('BasicCtrl20', function($scope, $http) {
  $http.get("/concept_db")
  .then(function(response) {
      $scope.gridOptions4 = response.data;

  });

});

在此我的代码中

<div class="container">
  <div ng-app="myApp" ng-controller="BasicCtrl20"> 
   <div class="row">
<span style="line-height:30px"><br></span>

<div class="toggles">
   <button id="showall">전체 제품 보기</button> 
  <button id="furniture">가구/인테리어</button>
  <button id="homeappliances">디지털 가전</button>
  <button id="life">생활/건강</button>
  <button id="sport">스포츠/레저</button>
  <button id="delivery">출산/육아</button>
  <button id="fashion">패션잡화</button>
</div>

<div class="posts">
    <div class="gallery">
        <div ng-repeat="gridoptions in gridOptions4">
            <div class="{{gridOptions.class}}">
                <div class="gallery-item">
                    <a href="{{gridOptions.main_href}}">
                        <div class="gallery-item-image">
                            <img ng-src="{{gridOptions.imgsrc}}">
                        </div>
                    </a>
                    <div class="gallery-item-description">
                        <p align="center">{{gridOptions.name}}</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
</div>

并重新使用

and reuslt

我想从数据库导入数据。

I want to import data from the database.

控制台日志结果

console log result

推荐答案

您有一堆元素,因此显然有某物 ng-repeat 不会因错误或稀疏而创建20个元素。

You have a bunch of elements, so there is clearly something there. ng-repeat does not create 20 elements from an error or thin air.

但是字段名称可能是错误的。它不是名称(或名称实际上在数据库中的每个项目上都是空的!)。检查您是否正确输入了字段名称。也许是大写的 Name NAME 或拼写错误的 naem 。或完全不同的内容,例如 label title

But the field name is probably wrong. It is not name (or name is actually empty on every item in the database!). Check that you got the field name right. Maybe its upper case Name or NAME or mispellt naem. Or something completely different like label or title.

最简单的方法是在获取数据时记录数据,然后亲自查看。

the easy thing to do is to log the data when you get it, and see for yourself.

.then(function(response) {
    console.log( response.data );  <-- look in the console!
    scope.gridOptions4 = response.data; 

或者因为它是GET -request。右键单击控制台中的链接 XHR完成加载:GET https:// localhost:3000 / concept_db。<-右键单击,打开
可能不是最容易阅读的内容,但是只需快速浏览一下数据就可以这么快。

Or since it's a GET-request. Right-click that link in your console XHR finished loading: GET "https://localhost:3000/concept_db". <-- Right-click, open in a new tab. It might not be the most easy thing to read, but it's a such a quick thing to just take a peek at data so you know what you are working with.

这篇关于如何修复我的代码? angularjs,ejs代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆