Showing posts with label link. Show all posts
Showing posts with label link. Show all posts

Tuesday, June 20, 2017

Angular/Ionic not updating an image src when ng-src is empty

The Angular ngSrc directive serves to properly set an image src via Angular. As anything in Angular, it updates the image as soon as the contained Angular expression changes. However, when the ng-src attribute is empty, Angular will not empty the src attribute. To overcome this, use the trick below.
<img ng-src="{{ element.image || '//:0' }}" />

Background

The ngSrc directive explicitly returns when the attribute value is false. As a workaround, set a "blank" image src when the image is empty. As somebody on Stackoverflow writes, //:0 serves this purpose: It adopts the current protocol, omits the hostname and sets the port to zero, which is invalid and should be killed by the network layer.
As a result, Angular should now correctly empty the src attribute when ng-src empties.


Thursday, February 12, 2015

Smooth Scroll Using jQuery

Smooth Scroll Using jQuery Code:


$(function() {
  $('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        $('html,body').animate({
          scrollTop: target.offset().top
        }, 1000);
        return false;
      }
    }
  });
});

Thursday, January 23, 2014

Add New Line On Mailto Syntax

This link needed to include a subject, CC, BCC and body text.

As the code used for html emails is still quite basic, so that all possible email programs can read them well, and I did not want to risk using a javascript based obfuscator I had to use the mailto syntax when usually.

The MailTo command can do more than enter a single e-mail address in the “Send To” field while activating your e-mail program.

Address message to multiple recipients
, (comma separating e-mail addresses)

Add entry in the “Subject” field
subject=Subject Field Text

Add entry in the “Copy To” or “CC” field
cc=id@internet.node