0

Here is my angular controller: 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);
   } ]);

and this is my HTML page :

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

Sharethis button is displaying but when share something it display Angular syntax not its value.

Here is the example what it is shared

no any console error

2
  • Do you see any error message in developer console ? Commented Oct 31, 2015 at 4:56
  • <div ng-model="greeting"> This might be the error.. please remove ng-model from the <div> Commented Oct 31, 2015 at 5:29

1 Answer 1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.