Created
December 22, 2017 21:37
-
-
Save n1lesh/738ba437008f4ebdd9871cfd216eed65 to your computer and use it in GitHub Desktop.
Adding ld+json structured data to AngularJs app Raw - Rich Card Directive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('home', []); | |
app.directive('richcard', ['$sce', '$filter', function ($sce, $filter) { | |
return { | |
restrict: 'EA', | |
link: function (scope, element) { | |
scope.$watch('ld', function (val) { | |
var val = $sce.trustAsHtml($filter('json')(val)); | |
element[0].outerHTML = '<script type="application/ld+json">'+ val + '</script>' | |
}); | |
} | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment