将ng-repeat放在组件上

时间:2017-09-04 14:10:55

标签: javascript html angularjs angularjs-ng-repeat

我有一个组件,其中包含一个表和另一个组件; 我想在作业组件上使用ng-repeat作为<tr>表格行。

我写的模板文件上的

<td>1{{vm.jobobj.title}}</td>
<td>2{{vm.jobobj.description}}</td>
<td>3{{vm.jobobj.publish_date}}</td>
<td>4{{vm.jobobj.first_name}}</td>
<td>5{{vm.jobobj.last_name}}</td>
<td>6{{vm.jobobj.location}}</td>

在另一个html模板页面上,这个:

<table class="table is-responsive">
    <thead>
        <tr>
            <th>Header A</th>
            <th>Header B</th>
            <th>Header C</th>
            <th>Header D</th>
            <th>Header E</th>
        </tr>
    </thead>
    <tr ng-repeat="job in vm.jobs" jobobj='job'>
        <job></job>
    </tr>
</table>

在js:

(function() {
   'use strict';

   angular
       .module('lanser')
       .component('jobsList', component());

   function component() {

       function componentController(JobsService) {
           var vm = this;
           vm.title = "jobs"
           JobsService.httprequestFunc(callbackJob);

           function callbackJob(resdata, where) {
               vm[where] = resdata.data;
           }

       }

       return {
           bindings: {},
           controller: ['JobService', componentController],
           controllerAs: 'vm',
           templateUrl: '/components/jobs-list/jobs-list.html'
       }
   }

}());

不幸的是,它没有用。

0 个答案:

没有答案
相关问题