代码之家  ›  专栏  ›  技术社区  ›  persia

symfony网页包encore angularJS

  •  0
  • persia  · 技术社区  · 6 年前

    我从Symfony3进行了迁移。4至SF4/挠性。 我在SF3中使用了assetic/bundle。4但现在我尝试用symfony/webpack encore来代替它。

    当我开始使用所有东西时,一切都正常,但在我的页面中,我无法显示webservice中返回的值。

    在我的topTripsController中,a使用webservice获取对象列表,然后我尝试渲染它们

    <div ng-controller="topTripsController as homeNotLogged">            
    <div data-ng-repeat="trip in homeNotLogged.trips track by $index" >
                <a ng-if="trip.cover.url " id="trip-||$index||">
    
                    <h2 class="trip-title" style="font-size: 14px; font-weight: bold" ng-bind="trip.name | capitalize">
                    </h2>
                    <div class="trip-date">
                        <span class="trip-title-first_name" ng-bind="trip.profile.name"> </span>
                        <span > · </span>
                        <span class="trip-title-from-date" ng-bind="trip.fromDate | date:'MMM, y'"> </span>
                    </div>
                </a>
                </div>
        </div>
    
     {% block javascripts %}
         {{ parent() }}
         <script src="{{ absolute_url(asset('build/js/pages/index.js')) }}" ></script>
    
     {% endblock %}
    

    当我写作时

    {{trip }}
    我得到了这个结果
     {"Id":15,"Profile":{"Id":2,"Name":"Alex Fergusson","URLname":"alex","Picture":{"Url":"d2d1117d023f81739aa7681fb60b98e92208d8c7.jpeg","Alt":""}},"Slug":"the-ultimate-one-week-istanbul-itinerary-and-guide","Themes":[{"Id":938,"Name":"Art & Design","Slug":"art-design"},{"Id":943,"Name":"History","Slug":"history"},{"Id":944,"Name":"Local Culture","Slug":"local-culture"}],"Name":"The Ultimate 5 Days Istanbul Itinerary and Guide","Cover":{"Url":"cb33d105cb7eaa59a912fac1df5e9c86d1562588.jpeg"},"Description":"vaoila dsvdvsdvsdv","FromDate":1480118400000,"NbrViews":1405,"NumCheckin":38,"NumPhoto":209,"NumLike":203,"NumComment":24,"Tigr":61.808134736842,"Published":true,"MapLines":true,"ToDate":1511005270,"DatesKnown":true,"Duration":358,"CreatedAt":"2017-07-17T09:05:47+02:00","UpdatedAt":"2018-04-02T15:37:34+02:00","Disable":false,"GooglestaticUrl":"the-ultimate-one-week-istanbul-itinerary-and-guide-travel-itinerary-1509033384.png","MonthViews":0}
    

    如果我这样做了

     {{trip.id}} {{trip.name}} 
    或绊倒。我没有任何结果,但我知道这些属性不是空的。

    此问题仅在使用wepback时出现angularJS@1.5.8在SF4项目中。

    有什么想法吗?

    1 回复  |  直到 6 年前
        1
  •  0
  •   Luillyfe    6 年前

    正如Json所建议的,您应该这样做,

     {{trip.Id}} {{trip.Profile.Id}} {{trip.profile.Name}}