2

リモート データでsmart Table eを使用しようとしましたが、出力が得られません。ajaxデータではstSafeSrc属性を使用する必要があるというドキュメントを読んでいますが、明らかに何か間違っています。

私のマークアップは次のようになります

<div class="content">
    <div class="container">

{% verbatim %}
{{ rowCollection }}

<button type="button" ng-click="addRandomItem(row)" class="btn btn-sm btn-success">
            <i class="glyphicon glyphicon-plus"></i> Add Feed
</button>

<table st-table="displayedCollection" st-safe-src="rowCollection" class="table table-striped">
    <thead>
    <tr>
        <th>Feed Name</th>
        <th>parsed Items</th>
        <th>Feed Link</th>
        <th>Feed Type</th>
        <th>Import</th>
        <th>Categorize</th>
    </tr>
    </thead>
    <tbody>

    <tr ng-repeat="row in displayedCollection">
        <td>{{row.feed_type}}</td>
        <td>{{ row.id }}</td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    </tbody>
</table>
{% endverbatim %}
</div>
</div>

コントローラ

october.controllers['dashboard/feeds'] = function ($scope, $filter , $request) {
    $.request('onFeeds', {success: function(data, scope){
        this.success(data).done(function() {
            $scope.rowCollection = [];
            $scope.rowCollection = angular.fromJson(data.result);
            $scope.displayedCollection = [].concat($scope.rowCollection);
            console.log($scope.rowCollection); // Array of Objects is present
        });
    }
});

}
4

1 に答える 1

2

見た目ではこれを使っている

https://github.com/responsiv/angular-plugin

コントローラーのコードが間違っています。$.request()の代わりに呼び出しています。$request()これは、$requestサービスが実際に http リクエストをプロキシするものです。これが、機能しているように見える理由です。しかし、実際には彼らのサービスを介してhttpリクエストを行っているわけではありません.Angularの内部にあります.Angularの外部で、彼らが使用するサードパーティのライブラリを介して作成しています.

コントローラーを次のように変更する必要があります。

october.controllers['dashboard/feeds'] = function ($scope, $filter , $request) {
    $request('onFeeds', {success: function(data, scope){
        this.success(data).done(function() {
            $scope.rowCollection = [];
            $scope.rowCollection = angular.fromJson(data.result);
            $scope.displayedCollection = [].concat($scope.rowCollection);
            console.log($scope.rowCollection); // Array of Objects is present
        });
    }
});

}

その後、彼らの$requestサービスが呼び出されます$rootScope.$apply()- 行 110 を参照してください。

https://github.com/responsiv/angular-plugin/blob/master/assets/js/angular-bridge.js

于 2014-12-22T18:27:21.950 に答える