在以addthis not expression值共享时共享角度表达式

时间:2015-10-31 03:54:34

标签: angularjs html5 sharethis

这是我的角度控制器:      var myApp = angular.module('myApp',[]);

  myApp.controller('GreetingController', ['$scope', '$sce',     function      ($scope, $sce) {
  $scope.greeting = 'my test goes here';
  $scope.url = "http://google.com";
  var shartthis = "<div addthis-toolbox class='addthis_toolbox   addthis_default_style addthis_32x32_style' addthis:url='{{url}}' ng-attr-addthis:title='{{greeting}}'><a class='addthis_button_facebook'></a><a class='addthis_button_twitter'></a> <a class='addthis_button_google_plusone_share'></a><a class='addthis_button_compact'></a><a class='addthis_counter addthis_bubble_style'></a> <script type='text/javascript'>var addthis_config = {'data_track_clickback': false, 'data_track_addressbar': false ,};</script></div>";
  $scope.shartthishtml = $sce.trustAsHtml(shartthis);
   } ]);

这是我的HTML页面:

<body ng-controller="GreetingController" ng-model="greeting">
<div ng-model="greeting">
{{greeting}}
</div>
<div ng-bind-html="shartthishtml"></div>

Sharethis按钮正在显示,但在分享内容时,它会显示Angular语法而不是其值。

Here is the example what it is shared

没有任何控制台错误

1 个答案:

答案 0 :(得分:1)

myApp.controller('GreetingController', ['$scope', '$sce',     function      ($scope, $sce) {
  $scope.greeting = 'my test goes here';
  $scope.url = "http://google.com";
  var shartthis = "<div addthis-toolbox class='addthis_toolbox addthis_default_style addthis_32x32_style' addthis:url='{{url}}' ng-attr-addthis:title='{{greeting}}'><a class='addthis_button_facebook'></a><a class='addthis_button_twitter'></a> <a class='addthis_button_google_plusone_share'></a><a class='addthis_button_compact'></a><a class='addthis_counter addthis_bubble_style'></a> <script type='text/javascript'>var addthis_config = {'data_track_clickback': false, 'data_track_addressbar': false ,};</script></div>";
  $scope.shartthishtml = $sce.trustAsHtml(shartthis);
   } ]);





 <body ng-controller="GreetingController">
<div>{{greeting}}</div>
<div ng-bind-html="shartthishtml"></div>
</body>