2014-10-28 38 views
0

enter image description here我使用wordpress API和範圍輸出angularjs我有問題來解析返回的CSS。AngularJS解析CSS代碼

對於HTML解析我一直在使用

<div ng-repeat ="article in post"> 
    <div ng-bind-html="article.content"> 
     {{ article.content }} 
    </div> 
</div> 

angular.module('blancAppApp') 
    .controller('SlugCtrl', function ($scope, $http, $routeParams) { 

    $http.get('/wp-json/posts/?type=post&type=page&filter[name]=' + $routeParams.slug).success(function(res){ 
     $scope.post = res; 
     return $scope.post; 
     console.log($scope.post); 
    }); 
}); 

這一項工作正常,但在CSS我有以下的原始輸出

#gallery-1 { margin: auto; } #gallery-1 .gallery-item { float: left; margin-top: 10px; text-align: center; width: 50%; } #gallery-1 img { border: 2px solid #cfcfcf; } #gallery-1 .gallery-caption { margin-left: 0; } 

JSON

\n<style type='text\/css'>\n#gallery-1 {\nmargin: auto;\n}\n#gallery-1 .gallery-item {\nfloat: left;\nmargin-top: 10px;\ntext-align: center;\nwidth: 50%;\n}\n#gallery-1 img {\nborder: 2px solid #cfcfcf;\n}\n#gallery-1 .gallery-caption {\nmargin-left: 0;\n}\n<\/style>\n 
+1

什麼是你想實現換行(\ n)的?詳細說明,舉例說明。 – 2014-10-28 20:17:38

+0

我做了一個更新 – fefe 2014-10-28 20:21:53

+0

,看起來像有效的CSS給我。我仍然不明白你想要達到的目標,你的代碼是什麼,你期望它做什麼以及做什麼。 – 2014-10-28 20:25:53

回答

0

試試你的包裝紙CSS風格標籤。

刪除/的轉義,你並不需要一個(開始和結束標記。)

也嘗試刪除

+0

在PHP方面已經包裝 – fefe 2014-10-28 20:39:50

+0

周圍的輸出是怎樣的,請張貼周圍的dom,以及如何在網絡督察(f12) – 2014-10-28 20:44:17

+0

響應看起來像我一直在發佈這部分的JSON – fefe 2014-10-28 20:45:33