element[0].outerHTML
?
On Sunday, September 21, 2014 2:01:34 PM UTC+2, Tomas Soukup wrote:
>
> I have an attribute directive which formats link based on browser and
> logged user - it is installation link of browser extension:
>
> angular.module('cp.system').directive('installExtLink', ['Browser',
> 'FeatureFlagsService', 'CurrentUser', function(Browser,
> FeatureFlagsService, CurrentUser) {
> return {
> restrict: 'A',
> link: function ($scope, element, attrs) {
> function updateLink(element) {
> if (Browser.isChrome) {
> element[0].href = "#";
> element[0].onclick = function () {
> return portadi_installExtension();
> };
> } else if (Browser.isSafari && FeatureFlagsService.safariLoginEnabled()) {
> element[0].href = portadi_getSafariExtensionUrl();
> }
> }
>
> CurrentUser.onLoggedIn(function () {
> updateLink(element);
> });
> }
> };
> }]);
>
>
> When I include it in html, everything works as expected:
>
> <a cp-install-ext-link>Install extension ...</a>
>
>
> So far good. In our app, we show messages in header section via:
> <span ng-bind-html="message.html"></span>
>
>
> Where message is current message.
>
> Now I would like to show the link in the message. When I format html by
> hand and include it in message variable, everything works as expected. i.e.
> if (Browser.isChrome) {
> return $sce.trustAsHtml('Portadi requires a browser
> extension to work.<br>Please install extension from <a href="#"
> onclick="return portadi_installExtension();">Chrome Web Store</a>.');
> }
>
>
> I would like to use the directive and include compiled html into the
> message.
>
> var element = $compile('<a cp-install-ext-link>Install extension ...</a>'
> )(scope)
>
> How can I include resulting element into the message.html? I need to get
> html as string, but I couldn't find any method to do it.
>
> All examples I have read use some sort of element.append... but I don't
> want to append new element, I just want to pass the html to section where
> we show also other messages.
>
> Thank you,
>
> Tomas
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.