2017-01-17 10 views
0

私はmain.controller.jsの中に単純なjsonオブジェクトを持っています。指令がトリガーされていません

$scope.sections = [ 
    { 
     id: "landing", 
     description: "<div><img pinch-zoom src='public/img/model.png'></div>" 
    } 
]; 

そして、私の意見では、私は私の$scope.sectionsをループng-repeatを持っています。

<md-content> 
    <div ng-repeat="section in sections"> 
     {{ section.description }} 
    </div> 
</md-content> 

しかし、私はIMGに添付ディレクティブが発射されていない{{ section.description }}を出力していたとき。あたかも無視されているかのようです。ここで出力されます - 私のピンチズームが完全に除去されています

<img src='public/img/model.png'> 

私はNGリピート内に入っていない画像にディレクティブを適用する場合は、指示火災だけで罰金。

私はng-repeatの中で以下を試しましたが、役に立たないです。

<div ng-bind-html="section.description"></div> 
+0

使用をきれいにする$のサニタイズと$ SCEを使用し、角度のアプリケーションのモジュールをサニタイズ。イメージがレンダリングされないのは、htmlタグの角が無視されているためです。 –

+0

@AniruddhaDas:画像がレンダリングされますが、ディレクティブは表示されません。だから私はイメージがうまくいくのを見ますが、その指示はそこにはありません。 – Mike

+1

今すぐ入手。 angularjsのhtmlをコンパイルしようとします。 –

答えて

0

HTML

<script> 
    angular.module('sanitizeExample', ['ngSanitize']) 
     .controller('ExampleController', ['$scope', '$sce', function($scope, $sce) { 
     $scope.snippet = 
      '<p style="color:blue">an html\n' + 
      '<em onmouseover="this.textContent=\'PWN3D!\'">click here</em>\n' + 
      'snippet</p>'; 
     $scope.deliberatelyTrustDangerousSnippet = function() { 
      return $sce.trustAsHtml($scope.snippet); 
     }; 
     }]); 
</script> 
+0

これにはimgタグhtmlの中の指示名が含まれています。しかし、この指令はまだ発射されていません。 – Mike

関連する問題