2015-01-19 5 views
1

angularjs 라이브러리를 사용하여 테이블을 만들었습니다 : angular-smart-table. 이것은 괜찮 았지만 더 많은 기능을 원했기 때문에 jquery mobile을 사용하고 싶습니다. 내가 겪고있는 문제는 표가 제목과 함께 형성되고 있지만 반복되는 행은 데이터를 표시하지 않으며 js 디버깅은 오류를 표시하지 않는다는 것입니다.jquery 모바일 테이블에 angularjs 채우기

HTML :

<body ng-controller="MyMainController as cont"> 
    <section ng-controller="PanelController as panel"> 
     <span> 
      *span items* 
     </span> 
     <div class="panel" ng-show="panel.isSelected(1)"> 
      <table data-role="table" id="table-custom-2" data-mode="columntoggle" class="ui-body-d ui-shadow table-stripe ui-responsive" data-column-btn-theme="b" data-column-btn-text="Columns" data-column-popup-theme="a"> 
       <thead> 
        <tr class="ui-bar-d"> 
         <th></th> 
         <th data-priority="1" st-sort="account">Account #</th> 
         <th st-sort="name">Campaign Name</th> 
         <th data-priority="4">Comments</th> 
         <th data-priority="2" st-sort="priority">Priority</th> 
         <th data-priority="2" st-sort="zipCode">Zip Code</th> 
         <th data-priority="2" st-sort="address">Address</th> 
         <th data-priority="2" st-sort="status">Status</th> 
        </tr> 
       </thead> 
       <tbody> 
        <tr ng-repeat="row in cont.tableRows"> 
         <td>{{row.checked}}</td> 
         <td>{{row.account}}</td> 
         <td>{{row.name}}</td> 
         <td>{{row.comments}}</td> 
         <td>{{row.priority}}</td> 
         <td>{{row.zipCode}}</td> 
         <td>{{row.address}}</td> 
         <td>{{row.status}}</td> 
        </tr> 
       </tbody> 
      </table> 
     </div> 
     <div class="panel" ng-show="panel.isSelected(2)" id="map-canvas"> 
      Map 
     </div> 
    </section> 
    *my javascript tags* 
</body> 

JS : 내가 말했듯이

(function(){ 
var myVar = angular.module('cont', []); 

myVar.controller('MyMainController', ['$scope', '$filter', function (scope, filter){ 
    scope.tableRows = [ 
    { 
     checked: false, 
     account: 1, 
     name: "Name1", 
     comments: "Comments`", 
     priority: "High", 
     zipCode: 11111, 
     address: "Address", 
     status: "Active" 
    }, 
    { 
     checked: true, 
     account: 2, 
     name: "Name2", 
     comments: "Comments2", 
     priority: "Medium", 
     zipCode: 22222, 
     address: "Address2", 
     status: "Active" 
    }, 
    { 
     checked: false, 
     account: 3, 
     name: "Name3", 
     comments: "Comments3", 
     priority: "Low", 
     zipCode: 33333, 
     address: "Address3", 
     status: "Active" 
    }, 
    { 
     checked: false, 
     account: 4, 
     name: "Name4", 
     comments: "", 
     priority: "Low", 
     zipCode: 44444, 
     address: "Address4", 
     status: "Active" 
    }]; 
}]); 

leadPlanning.controller('PanelController', function(){ 
    this.tab = 1; 
    this.selectTab = function(setTab) { 
     this.tab = setTab; 
    } 
    this.isSelected = function(checkTab) { 
     return this.tab === checkTab; 
    } 
}); 

})(); 

, 열 머리글과 행이 잘 표시하지만 실제 데이터가 날 리드하지 않는 여기 내 코드입니다 내 반복에 문제가 있다고 생각합니다. 그 전에 실제로 데이터를 표시 한 테이블은 <table> 태그를 제외하면 기본적으로 동일한 코드입니다. st-table="tableRows" (스마트 테이블 라이브러리의 경우) 및 내 반복은 ng-repeat="row in tableRows"입니다. 이것은 처음으로 angularjsjquery mobile으로 작업하기 때문에 도움이 될 것입니다.

답변

2

당신이 scope.tableRows @ 컨트롤러 인스턴스에 하지 부착 tableRows을 가지고 있기 때문에 그것은 반복하지 않는 대신 그것은 범위에 있고 당신은 cont.tableRow를 수행하여 컨트롤러 인스턴스 별명에서 참조된다.

시도 : -

this.tableRows = [... 

Plnkr

+0

는 내가 그것을 느끼는 것은 간단한 일이었다 있었다. 하지만 완벽하게 이해합니다. 완벽하게 작동합니다. –

+0

@ RyanSayles 안녕하세요. :) – PSL

관련 문제